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
11 views

DependentDropdown + AjaxAddMore

I have a custom form in which I'm using both the DependentDropdown and AjaxAddMore form examples from the example module. I've simplified the code below to focus on the issue. The dropdowns function ...
1
vote
0answers
35 views

How to validate a modal form?

I have a custom module which adds a button to a node form. The button opens another node form in a modal and when submitted, it takes the entity created in the modal and fills in an entity ref field ...
1
vote
1answer
31 views

hook_form_alter() Ajax suffix replace

I'm trying to rewrite a form item's suffix on an AJAX callback and it keeps prepending the first choice and then doing nothing else. My code: function my_dashboard_form_alter(&$form, \Drupal\Core\...
2
votes
0answers
26 views

Different 'Items Per Page' on different pagination while using 'views_infinite_scroll' module

I am using views_infinite_scroll module to load more nodes with 10 nodes on every click and views AJAX is enabled. I am working on a requirement like as, I have 100 total nodes and getting in a view ...
2
votes
0answers
62 views

Validate a form multiple times

Is it normal that my validateForm method in Form API doesn't trigger second time i call it? And if yes, how do i trigger it multiple times? I've got multistep form and i want to validate each step ...
0
votes
0answers
22 views

Alter Address field in order to add a list of cities

I need to alter the address field because I want to transform the locality textfield in a nested select box along with administrative_area value. I've tried to do that with a hook widget_alter, form ...
0
votes
0answers
12 views

How to show inline error messages when submitting webform using AJAX

I have a drupal7 setup. I have a webform, which I am submitting using ajax. I have implemented a nice solution given over here. Everything works fine including validation and after submission messages....
0
votes
1answer
20 views

How to use ajax callback on auto complete field inside a block settings form?

public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $selected = 'value of a field'; $form['node'] = [ '#type' => '...
-2
votes
0answers
38 views

How can I get a pseudo field to support an ajax form?

I am getting an error when I load a form in a pseudo field on a node. "An AJAX HTTP error occurred.↵HTTP Result Code: 200" Any idea why Ajax forms throw an error when loaded in a pseudo ...
0
votes
1answer
29 views

Ajax callback never called / triggered

I'm working on a payment gateway, so I've created a BasePaymentOffsiteForm form where I'm trying to make an ajax callback, but it is not working. Can you help me to know what is wrong with my code? ...
-2
votes
0answers
29 views

Ajax form validation example with FormStateInterface

I'm unable to find a proper working example for Ajax form validations which will highlight the field with FormStateInterface methods like setErrorByName Will be great if someone can share a simple ...
0
votes
0answers
22 views

Ajax callback values not found with upload managed_file field

I have a custom module in drupal 8 that has a few sections that utilize Ajax updates. I also have a "managed_file" field (Form API). The ajax works fine and updates two dependent fields, but the ...
0
votes
0answers
22 views

Ajax callback values not found when the form is submitted

I have a custom form. "instrument_dropdown" fields populate via ajax after selection of "instrument_family_dropdown" select field. It works fine if i does not add upload field. When i add upload file ...
0
votes
1answer
29 views

Is filtering using images possible?

Novice here. I'm on Drupal 7. I have a content type with a title, image and body field. I've created two views to display that content. The two views are on a page and I need help connecting them so ...
0
votes
0answers
21 views

Is there any native way to implement AJAX form submission without a button?

I need to implement a form that automatically saves data on each element change. So I can add a button with ajax callback and trigger mousedown on this button on "change" event using jQuery. And ...
0
votes
0answers
31 views

WidgetBase with Ajax Callback and manipulate #tree values

After many tries, maybe someone can help me here. I want a dynamic form field in a widget base, but I keep having problems. 1st Values of the submit button are lost after submit and can´t manipulate ...
2
votes
1answer
22 views

Setting value of form element from $form_state not working

I need to track previous values of a few form elements on a form to detect when they change to invalidate some other options on the page. Essentially, if the value of these fields change a field that ...
1
vote
0answers
28 views

Form alter + Unlimited Values + Entity Reference Field

There are two fields, News Type (Selectbox), News (Reference Entities, Unlimited option, autocomplete) When user select a news type, options of News fields needs to revised. Example: Selecting World ...
0
votes
0answers
22 views

Select Box change - remove the existing image

Fields: Image Field - field_image Selectbox Field - field_custom_language Testcase: On selecting a different value from Selectbox, uploaded image should be unset/removed. Issue: uploaded image is ...
0
votes
0answers
7 views

Saving the response of an Ajax callback of an element in a custom FieldWidget plugin

I have created a Field widget for Text fields in a content type. If a URL is entered into the text field, an ajax event callback is triggered on change and the URL is parsed to fetch the Open Graph ...
0
votes
0answers
19 views

Exposed filter override a textfield with a select field works only once

I have a code which works for using the title of a field as exposed filter select but it works only for the first time it is used afterwards (and because of ajax) it goes back to the state of field ...
0
votes
0answers
17 views

Second ajax select rebuilt by first does not fire

I have a form with 3 select fields. Selecting a value from the first should result in the second becoming populated, and this works. Similarly, when making a selection in the second, the third should ...
0
votes
1answer
21 views

Confirmation message not getting rendered when printing the elements seprately in twig and ajax is enabled

Iam using the following twig code in webform-submission-form--newsletter-signup.html.twig <div class="col-12 col-sm-12 col-md-6"> {{ form....
0
votes
0answers
26 views

How to add pager by ajax Call?

I have a form where you select a year from checkbox and then get all users registered for that year. Since the list can get very long I wanted to use a pager. Initially I just wrote an ajax call on ...
0
votes
0answers
46 views

Update radio button options after AJAX callback

I'm working on a form that submits via an AJAX callback that handles some class-toggling and populates a results table. Here's the callback that each input from the form calls: public function ...
0
votes
1answer
50 views

Change Image Alternative text on select box change

Fields: Image Field - field_image Selectbox Field - field_custom_language Testcase: On selecting a different value from Selectbox, Alternative text of the image field should be changed. Issue: ...
0
votes
0answers
25 views

Drupal 8 validation custom form with ajax submission not working

I built a custom block that renders a custom form, and such form submits via ajax. <?php namespace Drupal\contactform\Form; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface;...
0
votes
1answer
47 views

Need a current page's “Content Type” passed to a node.html.twig template (for a different content type) on page load, AND after ajax call

I'm trying to get the Content Type value of a node page (that the user is currently visiting - let's call it CT-1)... and feed that value as a variable into a DIFFERENT content type's node.html.twig ...
0
votes
0answers
41 views

How do I correctly load a webform using Ajax?

The page I need to make is a bit complex and my team and I face many problems with it. We need to have a page with multiples sections (just square blocs with text on it). Each section displays (on ...
0
votes
1answer
35 views

How to display data without html on ajax call?

How to display only content on ajax hit without html markup? what i am trying to do i have to show data on button click in profile dashboard(custom page) ,for this i have created controller file . ...
0
votes
0answers
73 views

AJAX loaded block with form not saving values

I have a page with multiple rows. I used a global view field to embed a view as a field. This embedded view has multiple editable fields (exposed forms). When I display more than 30 rows the global ...
0
votes
0answers
15 views

View with ajax enabled and webform as entity when there are no results is not sending webform

I have view with: Block: Map (Google Maps with dealers) Attachment (list of dealers below map) (inherit contextual filters: yes, inherit exposed filters: yes) Exposed filter visible for visitors (...
0
votes
0answers
26 views

Adding button with Ajax callback in node using preprocess_node

I have my_theme and my_project. Also have a file called my_project.php. There I have two functions and in both of them I have ALMOST the same structure: function my_theme_preprocess_node__foo(&$...
0
votes
0answers
49 views

How to load block content through ajax callback?

my_module.routing.yml my_module.content: path: '/my_module/path' defaults: _controller: '\Drupal\my_module\Controller\PageController::content' requirements: _permission: 'access content'...
0
votes
0answers
17 views

I want to add a pagination below the Twig rendered table updating the Twig rendered table and the pagination form next and previous button links

What I Have: I want to consume an external API, and show the results on the page. For this I have created a custom route attached to the controller with a custom Twig theme. On visiting this route, ...
0
votes
0answers
25 views

Ajax webform: “submit” javascript event is not fired?

We want to track the event "form submitted" via Matomo. It is working for forms which does not have AJAX activated: Drupal.behaviors.donationFormSent = { attach: function (context, settings) { $('...
0
votes
0answers
9 views

AJAX altered Entityform edit form not rebuilt 2nd time

Background I have an Entityform (using module with 7.x-2.0-rc4) with two select dropdowns, and I'm trying to alter it such that the second dropdown filters based on the first using AJAX. Current ...
0
votes
0answers
7 views

Ajax submit comments by pressing enter

I am using the Ajax comments module and display suite. https://www.drupal.org/project/ajax_comments When pressing submit button the comment form gets submitted via ajax as it is supposed to. When I ...
0
votes
0answers
22 views

Run AJAX cascaded

I am new here, just started to write a module. I am facing a issue to calculate a field and then calculate another field. Here in example, calculate amount in a line item, and on the field amount ...
0
votes
0answers
17 views

unknown Ajax call on custom views_exposed_filters while changing dropdown list

I have two exposed filters as select fields (County and District) using Hook_form_ID_alter. I'd like to alter the #options of District base on the County I selected to display related options. But ...
0
votes
1answer
85 views

hook_views_post_execute() don't work on AJAX View with exposed filters after 1st refresh

I have a View which returns 5 entities of the same type. AJAX - enabled, filters and exposed filters, all working fine. I need to add a new result, a user - defined entity, at the top of the View ...
0
votes
1answer
41 views

How can I set form values with Ajax?

I want to set the value of a textfield based upon the selection of a field above. You can choose a template and the textfield would have it as a value. This is the select field used to select the ...
0
votes
1answer
60 views

I want to call ajax callback function from another module's controller in Drupal 8. is it possible?

I am giving the code of my main form and the controller of another module where the ajax callback is written. Actually this ajax callback function will be used in different forms. So I want to create ...
1
vote
1answer
46 views

How to populate an Entity Reference field from a modal AjaxResponse?

I have an entity ref autocomplete field (reference to bundle A) in one of my bundles (bundle B). I want to add a button below this field which will open a modal for a bundle A create form. This code ...
0
votes
0answers
22 views

How do I reload an AJAX modal node add form without altering the behaviour of the original node add form?

I'm trying to edit the behaviour of node submit form (node type = 'class') but only when the form is submitted within an ajax modal window. Importantly, after the form in the modal window is submitted ...
0
votes
1answer
34 views

Why is my Ajax callback not returning anything?

I'm implementing an ajax callback function whats the issue with my code not returning anything. I'm new to backend <?php use Drupal\node\Entity\Node; use Drupal\Core\Form\FormStateInterface; ...
0
votes
1answer
27 views

Returning from ajax callback ruins view

Currently I am hooking into the add to cart form on my website. I added ajax to the edit quantity buttons like : $form_quantity[$key]['#ajax'] = [ 'callback' => 'update_cart_order', ...
0
votes
1answer
61 views

Ajax Multiple Callbacks is not working for first callback?

I have been trying to load the data to other select list field from the first select list callback. I want to change the two select list variables based on the first select list on changes, please ...
0
votes
0answers
19 views

managed_file FormElement submitting form upon file upload

How do i prevent managed_file(Browse Button) from calling submitForm function upon uploading file? I've added '#attributes' => [ 'submit' => FALSE, 'onclick' => 'return false' ] to no ...
-2
votes
1answer
48 views

CSS not work after applying ajax

I have a problem with css after applying ajax. I have an exposed form that I stylized. Before applying ajax it is: id="edit-field-price-value-min" After applying it changed to id="edit-field-price-...

1
2 3 4 5
48