Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [ajax]

Use it for questions about JavaScript/PHP code to create asynchronous web applications.

Filter by
Sorted by
Tagged with
0
votes
0answers
14 views

Search by title or SKU

Im having a problem when I try to search by SKU or whatever Im new in drupal Drupal core 7.67 | Drupal commerce 7.x-1.15. It does not allow me to finish the string and it delete some strings before I ...
1
vote
1answer
22 views

Change views exposed filter value only on page reload [duplicate]

Is there a clean way to alter a View exposed filter field, but only on page reload and not each time you submit the exposed filters form ? Example I have a View with exposed filters. When a user is ...
0
votes
1answer
26 views

How do I add an AJAX action on a select element in a ContentEntityForm to change the value of another select element

I have a ContentEntityForm with two select elements category and data_type. I want to load the options for the second select element when the first select element changes. I have tried to add the ...
0
votes
1answer
39 views

Hide certain field on form alter using AJAX

I have a webform created using interface, and need to hide some fields through button. Using form_alter I have added that button added AJAX call with it. Now I want to remove/hide certain element ...
1
vote
1answer
56 views

entity_autocomplete field thats added by ajax is not working

I have a field im adding to a node-edit form by ajax. the field is a simple taxonomy auto-complete field. when I add it directly in my form_alter it works, but when it's added by ajax, The ...
0
votes
0answers
15 views

How can I display custom error message using ajax submission?

I use the following code to submit form data using ajax: <?php namespace Drupal\ajax_form_submit\Form; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\...
-1
votes
0answers
10 views

Updating data in a form (set arguments from form)

Help me please. I would like set two arguments to ServiceGit.php from my Form.php and then get this again in my form. My app work so: I have $target & $target_id in ServiceGit. To default both ...
1
vote
0answers
60 views

How to load a view via ajax without breaking ajax functionality?

What ist the correct way to load a View via Ajax and not breaking the view ajax functionality like the pager? I tried it this way: In a template: <a href="/example-module/15?token=...
0
votes
0answers
33 views

Tableselect with return new response doesn't work

I'm newbie in drupal and I want to create contact list with dynamic search on ajax. I want to ajax load my tableselect. So I use return new Response(render($form)); where the form is tableselect. I ...
0
votes
0answers
14 views

Keep open state of a block when the page is reloaded

in a search_api view I have several facets links. These links are placed inside several block. If I open a facets block (collapse block), and I click on a facet link the page is reloaded...and the ...
1
vote
0answers
16 views

How to achieve dependent filters programmatically for views exposed form?

I have a requirement like Category and Sub-category should display as dependent filters. When I choose a Category next related sub-categories should show up in another field. These mapping is done in ...
0
votes
0answers
78 views

Ajax call for autocomplete reference field

I do not succeed to fire the ajax when an autocomplete reference field widget is populated or changed inside a paragraph form. TO BE MORE CLEAR: I Succeed when using a simple select list but not when ...
0
votes
0answers
10 views

Paginated ajax form with non-sql data

Using Drupal 8 I created a form to load data from a webservice with ajax below the form. Now i'm trying to add pagination to result, but the paginator is not been loaded, i'm doing something wrong?. I'...
0
votes
0answers
24 views

Pass rendered markup to redirect route

Drupal 8.7.x I have form that passes the outputted data into a template. This template with the data gets rendered into a string like so: : public function submitForm(array &$form, ...
1
vote
2answers
94 views

How can I display a message when “add another item” on an Inline Entity Form Multiple field is clicked?

In Drupal 8 inline entity form is there a "form_alter" or "submit handler" or some type of ajax callback for when a user clicks "add another item"? What I would like to do is display a message to the ...
0
votes
2answers
80 views

Paginated form with ajax checkboxes throws “The specified #ajax callback is empty or not callable”

Using Drupal 8.7.7 I have a form which consists of a paginated table of users. Each user row has a checkbox element in the form with an ajax event attached. This is essentially to allow me to store ...
0
votes
1answer
38 views

Create nodes unlimited times

I've been trying to ajaxify the node creation form, the purpose? Save the node and remains in the node creation page (Done) If the user clicks the save button again save a new node The second point ...
0
votes
1answer
51 views

AJAX form doesn't use ajax until cache clear

I'm defining an ajax form in my custom module (#ajax for submit). It is shown in custom block. But it works fine only on cache clear (on Drupal clear all caches or on ctrl+r in chrome). If I just use ...
0
votes
0answers
22 views

Dynamically created elements trigger wrong submit handler post AJAX event

I've found that dynamically created submit handles will adopt the first declared submit function in a form after an AJAX event has been processed. Demo code: <?php function form_test_main_form($...
0
votes
0answers
26 views

How to attach behaviors after an AJAX load in a view

I am trying to add a reset button to some exposed filters for my view. My code: (function ($, Drupal) { Drupal.behaviors.blog_filters = { attach: function (context, settings) { var ...
0
votes
1answer
20 views

Embedded View Form Ajax not working

I have a an embedded view display (type = embed) with an exposed form and pager. Ajax is enabled for the display. The pager reloads the display via ajax, however the form does not. I'm all but certain ...
0
votes
0answers
14 views

WebDriverTestBase can't place/see block configuration in an AJAX text

I am writing a functional test that checks the output of a page when a user has a specific cookie. Based on that cookie, I have a block powered by Ajax Block that injects block content personalized ...
1
vote
1answer
101 views

Load a block contents dynamically / via AJAX?

I need to have a custom block on the page (will be sitewide) that has two states - one for when a cookie is present and has a certain value, and the other for when that cookie is not there or the ...
0
votes
0answers
22 views

Help needed with ajax request from Jquery to callback function

I create the callback url 'swish_payment/request' in my hook_menu() function: function swish_payments_menu(){ $items['swish_payment/request'] = array( 'type' => MENU_CALLBACK, ...
0
votes
0answers
13 views

How to Create a Form with Ajax Output External to the Form?

What I want to achieve is: A form with a number of selects / textfields A div external to the form that contains information pertinent to the form's current input (i.e. not contained in the form ...
0
votes
0answers
38 views

No AJAX when user is logged in?

I am developing an e-commerce site for one of our customers for the first time with drupal. It is going pretty good so far but there is a weird misbehavior where I have no idea on how to handle it in ...
1
vote
0answers
16 views

8 - How can I update the entity reference fields of the form when I close the modal?

How can I update the entity reference fields of the form based on selection in the modal dialog when I close the modal ? I have a form and users starts fill the form. Then click on choose address ...
1
vote
1answer
26 views

Ajax webform do submit without ajax when it is loaded via ajax

I'm trying to load a node containing an ajax webform and add it to an existing div, this works fine, but when I click to next step, the form is submitted to the webform action path. Any idea? Thanks!...
0
votes
0answers
17 views

Override form field #value after ajax request sets it

First of all, here is the code: /** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $form['join_newsletter'] = [ '#type' => '...
0
votes
0answers
20 views

Update Entity Reference View based on form field selection

I have a Content Type called Licence which has two fields, field_product and field_billing_cycle. Both are Entity Reference fields, using the select Widget. The product content type has a multi value ...
0
votes
0answers
21 views

AJAX View not working with Webpack

I have a Drupal 8 website running in a Docker environment. I have an AJAX-enabled View that works perfectly fine when I am running my website on the URL provided by my Docker setup (http://back.d8....
0
votes
1answer
45 views

Show form errors before opening AJAX modal

I have a form that adds a product to the cart. The form uses AJAX to open a modal when the form is submitted. I want to show form errors (if any) before the modal opens and avoid opening it if there ...
0
votes
1answer
29 views

Form is not submitting after ajax callback

I have a form which has a checkboxes field. This field has an ajax callback attached $form['checkboxes'] = array( '#type' => 'checkboxes', '#title' => 'test', '#ajax' => array( '...
1
vote
1answer
36 views

Table in custom form + empty values in form_state

In a custom form I created a table element: // Table results. $form['table'] = [ '#type' => 'table', '#header' => $header, '#rows' => $rows, '#attributes' => ['id' =&...
0
votes
2answers
74 views

Ajax add command to open a new URL

in a custom module, I created a custom form. On this form, I have an ajax button to open a specific file (.pdf). Here is my code in a custom submit function : $url = 'myfileUrl'; $response = new ...
0
votes
2answers
59 views

AJAX Views with filter as path component

I have a view of Commerce products of type Print. The product type Print has a reference on a Taxonomy called Category. I setup the Category field as an exposed filter (dropdown) for my View page. The ...
0
votes
0answers
10 views

Reinitialize views ajax after embedding a view

I have installed an ajax_links_api module, which basically allows you to load pages via ajax. I got everything to work, however, there is an issue with views. In my view I have infinite scroll and ...
0
votes
1answer
69 views

Force download string as text file

I'm trying to return the results of a db_query as a raw text file. The php solution uses header() to instruct browsers to download content. I've attempted using header() in an AJAX callback function, ...
0
votes
2answers
49 views

Ajax validation only works when I am logged in as an administrator

I have created a custom contact form and I have set up an ajax inline validation. My form works very well. But Ajax validation only works when I am connected. When I am not logged in as an ...
0
votes
1answer
56 views

Should we document AJAX-callback parameters?

Considering the PHPCS warning: phpcs: Hook implementations should not duplicate @param documentation Is there any way to tell PHPCS that the function is an AJAX-callback (so that such warnings are ...
-2
votes
1answer
44 views

How can I create a new Paragraph item programmatically in an Ajax form handler?

I need to add Paragraph fields programmatically to an entity in an AJAX handler. This is my AJAX callback and how it's added: function mymodule_form_alter(&$form, \Drupal\Core\Form\...
0
votes
0answers
67 views

How to bypass “allowed values” validation for a select field (list_string)?

At the user account form, I've created two select fields (of type list_string) for state and city. The state field has a list of states for its allowed values config, and the city field has no values ...
0
votes
0answers
47 views

Error “An illegal choice has been detected. Please contact the site administrator.” [duplicate]

I get the error shown below while trying to implement dependent dropdown for country state as shown below while trying to submit form which implements AJAX in drupal 8 for country - state dropdown I ...
0
votes
0answers
31 views

isset(($_GET['variable'] ) not TRUE anymore after AJAX submit?

I have a variable e.g. for a search query which i save in the URL: .../page?variable=value I get this variable and save it as a global variable so i can use it in all functions of my file: if (...
0
votes
2answers
33 views

Form rebuild without using buttons

I'm trying to figure out how to rebuild a form without using a button click trigger. Instead, I'm looking to rebuild whenever a blur event occurs on a textfield. All non-button form types lack the #...
0
votes
0answers
44 views

How can I show view displays as Ajax tabs?

I would like to have a view with a Grid and a List tab (view displays) in Drupal 8. The URL should not change and the filter and pagination values should also be maintained when switching between ...
0
votes
1answer
23 views

How to add library if Ajax is enabled for view?

We have a view, myview, where Ajax is disabled. We created a custom library that would override the load more button's indicator so that we can use our own. However, we would only like to add this ...
0
votes
0answers
34 views

Updating $form_state of a form from a different form

I have a pretty complex process that combines two Drupal forms--1 widget form and 1 normal form. The first form (WidgetForm that extends the ImageWidget form) will allow the user to open a modal to ...
1
vote
0answers
42 views

Programmatically add more 'paragraphs' in form alter ajax call [duplicate]

I have a content type called repair that has a multi paragraph field (field_products) called Products. In the create new repair form I have an ajax button that fetches N number of products and ...
1
vote
0answers
20 views

Incorrect User data being loaded after save

I am running into some data inconsistencies when attempting to load user data after saving the data. Basically, I have a callback that will update a field on the current user object. In a simplified ...