Questions tagged [ajax]

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

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

How do I get the upload progress bar activated for image uploads?

I am on the latest version of D8, on a LEMP stack, and have PECL upload progress enabled. I’m also using cloudlare cdn modules for caching and similar, but not yet for any file storage. Looks like I’...
1
vote
1answer
28 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
29 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
41 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
8 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
0answers
33 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, ...
-2
votes
0answers
25 views

Views Infinite Scroll won't work

I'm trying to add 'Views Infinite Scroll' module to my Drupal 8 website, but it won't work :( Configuration of my View: Yeah I've checked AJAX I've selected "Infinite Scroll" as pager and checked '...
0
votes
2answers
48 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
49 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 ...
-1
votes
0answers
12 views

Ajax_command_replace a form, old form errors persists

I have a form made with 3 checkbox and one of them have a value that change in function of precedent forms choices. So I use the ajax_command_replace command to refresh my form like this : $...
-2
votes
1answer
29 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
36 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
30 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 ...
-1
votes
0answers
14 views

ajax with hook_form

how to use ajax callback on hook_form_alter ? i can modify title and value the field on /node/add first i create info.yml then module.. the module contain this.. <?php function ...
0
votes
0answers
24 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
1answer
25 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
38 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
11 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
32 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
34 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
17 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 ...
0
votes
1answer
29 views

Auto-submit exposed form

I'm currently working on a views exposed form block. I want the form to auto-submit using AJAX, whenever an exposed filter is changed. I have searched for this, but I couldn't find any tutorial or ...
0
votes
2answers
53 views

Run validation callback before ajax

The submit element on my form uses an ajax callback which sends out an email. I have a validation callback which I've added to this form, but it gets run after the ajax callback and so the email will ...
0
votes
0answers
34 views

Remove a widget item with an Ajax callback (in an entity browser widget)

[edit to add]: 1-The ajax callback is made from a field (field_company) inside the regular user_form 2-The logic and the callback definition reside inside the hook_form_alter of the user_form => ...
1
vote
1answer
33 views

where to put addCommand when implement ajax callback commands

i' m trying to load a dynamic value on every node of my site and i want to achieve this via ajax callback commands and writing custom module so i have a class in src/ajax folder of module like: ...
0
votes
1answer
52 views

Adding #ajax callbacks to form elements in HOOK_form_alter()

I'm trying to add an #ajax callback to a select element on a form that is created in another module on a Drupal 8.x site. When I add the #ajax callback using HOOK_form_alter() in my module, the Ajax ...
0
votes
0answers
11 views

Get replaced element value in ajax

On ajax callback I have replaced value on with replaceCommand> Value was displaying on browser but , while i have clicked on radios again and ajax callback again It will fetch the same old 1000 value ...
0
votes
0answers
31 views

What should I use instead of ajax_render()?

I want to create AJAX pagination on Drupal 8. With Drupal 7, I used the following code. $result = theme('load_more_friend_suggestions', array('friends' => $friends_list, 'info' => array('...
0
votes
0answers
21 views

Ajax based form doesn't work on new from element [duplicate]

I am creating some dynamic form element based on the dropdown selection. There are max 3 dropdowns and I want to run ajax on each dropdown on change event. When I clicked on the first dropdown(Level ...
1
vote
1answer
39 views

Focus problem when Ajax call for multiple fields calling the same callback function

I have implemented a custom form. I put same Ajax callback function for multiple field. When one Ajax call completes, I click on other field. But I can't unfocused previous field. Sometimes the Ajax ...
0
votes
0answers
17 views

Ajax in a template file to show the value of session variable

I have a webform in my node.tpl which action points to hook_menu url of a module. When the form submit happens, it compiles the form data in the custom module and stores the response value in a ...
0
votes
0answers
27 views

AJAX in callback function

I'm trying to convert old code written in standard HTML/PHP/Javascript/JQuery into a format (more) consistent with Drupal. The code consists of a form with interactive elements (regulated by ...
-1
votes
1answer
50 views

AJAX not working in views for anonymous users [closed]

I have a view in Drupal 8 with an exposed form with AJAX enabled. It works fine for admin user, but it doesn't for anonymous users. I have included in my theme libraries file: dependencies: - core/...
1
vote
1answer
37 views

What is the progress bar periodic update function return data?

In Drupal 7 from the function called with 'url/to/call/progressbar/update/function' (see below) you would return an array converted to JSON like this: drupal_json_output($message); I cannot find any ...
0
votes
0answers
16 views

Cannot get form values set in a ajax callback

In the hook_form_alter, I add 3 textfield form elements and 1 button with ajax callback: function zwznertags_form_alter(&$form, &$form_state, $form_id) { if($form_id == 'book_node_form') { ...
0
votes
0answers
19 views

How to maintain two domains in the same installation having different $base_url

I have published a new domain for my drupal installation. It has a fixed $base_url configured in settings.php. For example: https://www.olddomain.com.ar . It throws an ajax exception when I use a ...
0
votes
0answers
15 views

Search result page with tabs and ajax pagination

I need to create a results search page with those characteristics: The page will have different tabs (like the bootstrap ones so no page reload), each tab will only shows the relative content type. ...
0
votes
1answer
27 views

How can i add ajax callback to checkbox in drupal form?

I am using taxonomy manager module I want to add ajax callback to checkbox tree view for checkbox is checked condition but it is not working can some one please suggest me. I have modified the code ...
0
votes
0answers
17 views

How to fill a multi-value term reference field in a ajax callback in a node add/edit form?

The machine name of the term reference field is "field_persons", using the autocomplete_deluex widget. function zwznertags_form_alter(&$form, &$form_state, $form_id) { if($form_id == '...
1
vote
0answers
29 views

scrolling after posting drupal ajax form

I am working on an existing site which has a Drupal 8 multi-step form which uses Ajax Upon submitting the form (on the final step) the page scrolls to the top where a thank you message has been ...
0
votes
2answers
73 views

AJAX callback inside hook_form_alter()

I don't know how to implement AJAX callback in hook_form_alter(). The field is plain text by default and it is populated by NID (number) of the client company. The module name is "my_car". I didn't ...
0
votes
2answers
32 views

Ajax error render

I receive this error message when I try my custom form in Drupal 8. User error: "0" is an invalid render array key in Drupal\Core\Render\Element::children() This is the code I am using namespace ...
0
votes
1answer
35 views

Provide autocomplete field with user's Display Name

Drupal core already supports autocompletion of username fields. However is there a way to provide autocomplete for user's Display Name? Since this is a virtual field, a database query with % like ...
0
votes
0answers
28 views

form : I need to prepopulate an entity reference multi value field depending on select list

I need to prepopulate an entity refence field depending on a list selection field. If the user select liste "administrator" then ajax need to prepopulate the field with users asssociated to this list....
1
vote
2answers
33 views

How do I change the Views (Entity Reference) filter via AJAX?

I have an entity form that allows an admin to select a content type (checkbox) and an autocomplete field that is tapped into a VIEWS Entity Reference (via the Reference Method). Goal: What I would ...
0
votes
0answers
62 views

Ajax Issues with Drupal Layout Builder

We're trying to use the new Layout Builder to configure some of our content types. When we click the "add section" button under Manage Layout, we get the following errors: On the page in the console ...
0
votes
0answers
22 views

Private Message AJAX request is breaking theme by loading JavaScript code twice

I have a strange issue when using private message module together with the bootrap theme. I setup the block to select the conversation/thread on the left region. I noticed when I use this block ...
0
votes
1answer
69 views

How to get and apply current page query parameters from current AJAX request

I'm having a hard time figuring out how to do this. Essentially I have a table displaying users on a page. The table is paginated with the PagerExtender and sortable with the TableSortExtender. Each ...
2
votes
1answer
119 views

Calling a JS function after managed file has completed uploading

How can I call a JavaScript function after a file has completed uploading using the Drupal Form API (FAPI) managed_file element?
0
votes
1answer
50 views

Set and Get $form_state with ajax button submit function?

In my case, I need to get a list of config files to show in a form element. Extending from this Drupal Answers Q/A using form_state->set() inside ajax callback but cannot get the value back outside ...