Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [ajax]

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

0
votes
0answers
19 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
22 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....
0
votes
1answer
14 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 ...
-3
votes
0answers
12 views

File not deleted after successfully send message in private message module [closed]

I am sending message with file attachment. Message send successfully and also file but issue is that file not deleted from the file field after successfully message send. Please see attached sceen1, ...
0
votes
1answer
19 views

How to get values from a different function? [closed]

I have the following function in Drupal (Controller) that calls an API via AJAX. It is already returning values from the API but I want to take these values and use them on a private function that's ...
0
votes
0answers
15 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
19 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
26 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 ...
3
votes
1answer
23 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
41 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 ...
0
votes
0answers
14 views

form field description tags stay after ajax rebuild

When i rebuild my page via ajax e.g. with a button that dynamically adds additional form fields, the description tags (tooltips) of the Bootstrap theme that were shown to the user in the moment of the ...
-1
votes
0answers
16 views

How to use Ajax to dynamically render a new paragraph with DB data?

I'm kinda starting with Drupal 8 and I need some help. I have a dropdown in a custom block which options are taken from a DB. Now, I would like to create an Ajax callback that could take the value ...
0
votes
0answers
7 views

AJAX rebuild single form element

I'm trying to get an AJAX-enabled form working. Users should be able to tab between fields using the keyboard, and when a user tabs to the next element, I want the name span after the previous-focused ...
1
vote
1answer
24 views

Manually trigger AJAX from custom JavaScript

I'm in the process of developing a form where the user enters a UK postcode and the textfield is replaced by a select list. This all works quite nicely when using the blur event, but it is not always ...
0
votes
0answers
35 views

Ajax on Gmap marker placing

I've got a geofield and an address field on my content type, there is a geocoder module which can hide geofield and set it's value based on the addressfield value when the entity is saved. what I ...
0
votes
0answers
23 views

Modal does not handle errors on login

I have used 'use-ajax' class to render login form in a modal. I want to handle validation errors on same modal without closing it. On successful login it is redirecting correctly, but when an error ...
0
votes
0answers
23 views

Setting to reduce cache_form for ajax calls

I have a D7 site with the following seetings: I have a module that is adding an multistep ajax form to many pages, let's say to 80% of my pages. The form is loaded with different data, but the ...
0
votes
0answers
11 views

Drupal form element AJAX calls only if it has changed

I have a form with AJAX-enabled textfields. I currently have it working such that when a textfield loses focus, its AJAX callback is called. $form['entry'][] = array( '#type' => 'textfield', '#...
0
votes
0answers
34 views

Return an Ajax Response from EventSubscriber?

I am trying to return an ajax response when a user logs in while the page is loading post-login. /#1 approach was attaching an ajax callback to the user login form submit with form_alter. However ...
1
vote
2answers
28 views

Prevent form regeneration when a callback function is called through ajax

Here is the code for the custom form with a field(field_B) that calls an function through ajax. The issue is that I want the function (MY_MODULE_XYZ_function()) to be executed only once, when the ...
0
votes
1answer
41 views

How can I add custom client-side validation to a Webform field using advanced custom properties?

The setup: I have a Drupal 8 form created manually, and I would like to recreate it using Webform module. So far, I have managed to recreate everything (required fields and submission handler), but ...
0
votes
0answers
14 views

Vertical Tabs: Wrapper problem

I have a form with several fieldsets and i am thinking about adding a vertical tabs form field to turn the current fieldset to vertical tabs but i use a lot of AJAX in the fieldsets. The AJAX elements ...
0
votes
0answers
34 views

Adding AJAX to an existing form element?

I am trying to Ajaxify a node form element (field_unterbringung). When the user changes the value of an entity reference field (unterbringung) the markup should change from "old markup" to "new markup"...
0
votes
0answers
16 views

AJAX select field - $form_state not saved

SOLVED (see comments) I have a form with a select field (where you can select a title of a novel). This select field automatically writes a the respective ISBN of the novel into a textfield when a ...
1
vote
0answers
28 views

Redirect Page on Change of Exposed Filter

We have an All Articles view that is added to the http://www.example.com/articles page that is supposed to display all pages where content type is Article. The content type has a taxonomy term, ...
0
votes
0answers
28 views

Inline Entity Form hook_alter causes Ajax error on 'Add another' button

I created the module to hide some fields in my Inline Entity form. Although it works I faced the problem. I need to add multiple custom content nodes with Inline Entity Form. When my field setting ...
0
votes
0answers
29 views

How do I send variable from JavaScript to server?

I have been stuck on this for many days now and I am not sure how to proceed. What I would like to ultimately achieve: Get current user location coords using location.js library that I have linked to ...
0
votes
0answers
22 views

Dynamically set '#prefix' => '<div id=“wrapper_id”>'

I have a form with a select field (where you can select a title of a novel). This select field automatically writes a value (the rspective ISBN of the novel) into a textfield when a novel is chosen by ...
3
votes
1answer
44 views

how to prevent javascript from running again when an AJAX form is submitted

I have this code in a javascript file to hide some search filters... $('#views-exposed-form-faceted-search-page .form-type-select').once().hide(); The user can toggle the visibility of the filters ...
0
votes
0answers
17 views

Overriding values in AJAX dynamic form fields

I built a form based on that documentation page: https://api.drupal.org/api/examples/form_api_example%21src%21Form%21AjaxAddMore.php/class/AjaxAddMore/8.x-1.x of course I extended that form because I ...
0
votes
0answers
24 views

Replace select options

I have a form: public function buildForm(array $form, FormStateInterface $form_state) { // Disable caching on this form. $form_state->setCached(FALSE); $scheme_data; // code to ...
1
vote
1answer
35 views

Error when I try to call a form

Here is my class: <?php namespace Drupal\mais\Form; use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\...
0
votes
0answers
23 views

Missing values in $form_state['values'] when addding field through _form_alter after AJAX callback

I want to add a couple of fields to a content type form using AJAX and, upon validation, run a custom _submit callback to do something with those fields. My approach: 1. Alter the form adding a ...
0
votes
0answers
21 views

Get data from textfield dynamically in form

I would like to get data from textfield dynamically. Next i want to verify content from field and do sth(without refresh) $form['cont_but']['scan_field'] = array( '#title' => 'Scan:'...
1
vote
1answer
50 views

AJAX button - HTML in #value causes problems

i have an Ajax button, the code looks like this: class coolButtons { public function getFormFieldAjaxButton() { return [ '#type' => 'submit', '#value' => t('<i class=" ...
0
votes
0answers
9 views

How to properly render and alter a webform submission edit form via ajax

This is a really hard issue to put into words but I'll try my best. In this scenario, I'm rendering a submission edit form and attaching an ajax button to run a custom callback. I'm not sure if this ...
0
votes
1answer
19 views

How to remove the click event on an Ajaxified form's submit buttons?

I've created several forms with Drupal 8 directly in admin or with Form API. I've added some client side validation with this jQuery plugin : jQuery Validation Plugin. Everything works very well. Now ...
0
votes
0answers
28 views

$form_state values are empty after ajax $form modification

Im doing a module to generate form validation on field length, first i display a select of availble content types. When the target content type is selected an ajax request display the end of the form ...
0
votes
0answers
36 views

How to validated form with Ajax fields

I have a drupal custom form with two ajax dependent dropdown fields and five normal text fields. on form submit, all things are working fine except validation of form fields. when I put validations on ...
0
votes
1answer
32 views

How do I trigger a modal from a template that points to a controller returning an AJAX response

I am trying to trigger a modal from a twig. The path of the modal is a controller that returns an AJAX response as below: Routing code usgbc_myaccount.get_badges_evidence_controller: path: '/account/...
0
votes
1answer
39 views

Avoid repetitive API calling in form rebuild while submitting

I am calling external API in form build function. While submitting form gets rebuild and call external API again. How can I avoid repetitive API calls in the form's build function? I used form_state-&...
0
votes
0answers
26 views

How to switch between views displays through ajax

I do have a view with exposed filters and a quite hierarchical architecture of the data which demands multiple grouping and sorting criteria. because of different use cases, users need to change the ...
0
votes
0answers
13 views

Update programmatically (js) the images of a image field in edit form

I have an entity type which has an image field. I use the default form widget for this, and I can upload or delete the image. On the node edit form, I have also a pop-up widget with a javascript app ...
0
votes
0answers
15 views

Refresh title/block when validating a filter

I have built a views with filters. When we choose a filter, the results are displayed by ajax ('Use Ajax' option). I need to update the title of my views page, with the active argument of the view. ...
0
votes
1answer
36 views

Drupal 7 chosen module use ajax to fill the select

I have two select elements and depending on what I select in the first select element second should fill from ajax call. First one is the simple select second one use chosen. The problem is if I fill ....
0
votes
1answer
31 views

How can I update the values of an exposed view filter when another filter changes value?

I know there are several examples of this around, on a view with two exposed select list filters, I need to update the value of the second based on the value selected on the first. I can't even seem ...
0
votes
1answer
25 views

Form API + AJAX - Form doubles itself on submit

I've been looking for an answer to this for hours now. A) No matter what I do, the form will always be visible again after submit. How can I stop the from from displaying after a successful submit? ...
0
votes
2answers
48 views

how to implement Ajax callback on form_alter for entity field?

EDITED: I am able to display image for a field dropdown which have entity reference values to another content type. That is when a node content is edited or created. Note: I'm not creating form ...
0
votes
0answers
44 views

How to set #default_value for radio button on Ajax Callback?

I've a form having a radios and 'select list with Ajax callback event'. When user changed selection from the select box, I tried to set the default_value for radio button. but it doesn't work. In the ...
1
vote
1answer
63 views

Add custom ajax command to ajax response after webform is submitted

What I'm trying to do is to invoke some javascript after a webform is successfully submitted by ajax. To do that I followed this advice and created an EventSubscriber to intercept ajax response and ...