Questions tagged [ajax]

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

Filter by
Sorted by
Tagged with
1 vote
0 answers
49 views

#ajax not triggering on textfield or any fieldtype other then select

I'm completely clueless about the problem. I have tried to google but have not found any similar issues. My AJAX callbacks work only on the select field type, but I want to trigger ajax on textfield ...
Alex Pshegodskyi's user avatar
-2 votes
1 answer
92 views

Rendering for AJAX

Within my module I have a button that calls an ajax request. The controller for this request is to collect some data, then render a Twig template using that data. Using Drupal 10, how do I render the ...
Cy Jobes's user avatar
-1 votes
1 answer
62 views

Give all users including anonymous ones the option to add nodes of certain content types to a list like "interested", at least once

I'd like to give all users including anonymous ones the option to add nodes of certain content types to a list like "interested", at least once. The logic is identical to that of a shopping ...
alesios's user avatar
0 votes
0 answers
47 views

AjaxResponse in build() custom block

I want to add an AjaxResponse in build() custom block public function build() { $build['content'] = $this->getContent('field_header_text'); return $build; } This basic code works and I ...
Joouul's user avatar
  • 1
0 votes
1 answer
133 views

Why is my message not showing for anonymous user?

In a custom form, I have this Ajax submit: public function ajaxSubmit(array &$form, FormStateInterface $form_state) { $response = new AjaxResponse(); if ($form_state->hasAnyErrors()) ...
gbmapo's user avatar
  • 1,066
1 vote
0 answers
204 views

Why is CloudFlare blocking file uploads?

I have a simple form where people raise IT helpdesk requests (oh, the irony...) and this creates a case in CiviCRM. It's an unsophisticted but cheap helpdesk system for the few requests we get. A ...
ChumKui's user avatar
  • 169
0 votes
1 answer
62 views

Why doesn't my completion message show?

I have this form to handle a custom content entity: created by this code: public function buildForm(array $form, FormStateInterface $form_state, $contractId = NULL) { Some code to inialize ...
gbmapo's user avatar
  • 1,066
0 votes
0 answers
68 views

TriggeringElement not working properly for my ajax form

<?php namespace Drupal\demo\Form; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Component\Serialization\Json; use Drupal\node\Entity\Node; use \Drupal\...
Z CHAMP's user avatar
  • 62
0 votes
1 answer
121 views

Why does Ajax prevents managed_file to be displayed?

I have this form created by this code: public function buildForm(array $form, FormStateInterface $form_state, $contractId = NULL) { some initialisation code... $database = \Drupal::database(...
gbmapo's user avatar
  • 1,066
1 vote
1 answer
84 views

Can't access data posted from Dialog.ajax to dialog box

I am opening a simple dialog box from Ajax, using the following code- var exportActionDialog = Dialog.ajax({ dialog: dialogSettings, dialogType: 'modal', type: 'POST', url: '/web/admin/crm/...
ilechcod's user avatar
  • 113
-2 votes
2 answers
139 views

Revolution slider issue with AjaxResponse

I have an issue after drupal update to version 10 with Revolution Slider. This is an error I get: Exception Error: "Call to undefined method Drupal\\\\Core\\\\Ajax\\\\AjaxResponse::create()" ...
vradova's user avatar
0 votes
0 answers
57 views

Expired session - Invalid form POST data - Ajax

On my Drupal 7 I have a multisep form that uses ajax to validate and to submit the answer. The form is used for an authenticated or anonymous user to answer a set of questions. Everything is fine, ...
MMT's user avatar
  • 41
0 votes
1 answer
132 views

Loading webform in modal is too slow

I have webform with near 130 fields (text, entity checkboxes, radios, composite, etc) Use it in modal: <a href="/my-form?title={{node.id}}" class="webform-dialog" data-dialog-...
kazah's user avatar
  • 29
0 votes
0 answers
52 views

Node save button can be clicked while there is still running javascript which leads to unexpected behavior

We have Group module installed and a custom field. To be more specific, we can set a value of this field from a dropdown list depending on the selected group. The behavior is as follows: Open content ...
Eiki Hanai's user avatar
2 votes
2 answers
79 views

How to access validated values after AJAX callback when fields are nested in a container?

I have a custom form where I have a search field and button. After the users clicks the button, I load some items based on what they've entered into the search field. The problem that I'm having is ...
sonfd's user avatar
  • 7,881
0 votes
0 answers
142 views

Set form values based on ajax callback

I am creating a complexed multistep form based on data from an Excel document. The user can save parts of the form using AJAX save buttons and updated data from the Excel document are displayed in the ...
NicklasF's user avatar
  • 299
0 votes
0 answers
38 views

How can I get conditional logic working when embedding a webform?

When embedding a multi-page webform within a render array using #type => 'webform', it seems like there's a bug where the conditional logic of webform elements does not work. Note: The webform's ...
user1414202's user avatar
0 votes
0 answers
80 views

Ajax callback not returning options for checkboxes

I'm triggering an ajax callback on change event of a dropdown, this method returns additional form elements like text fields, number and checkboxes, but for checkboxes the options are not appearing at ...
Himanshu Lahare's user avatar
0 votes
1 answer
47 views

File Field client side validation not working

I am on Drupal 9.3.x I just discovered that File Field in node entity form which is marked as required, not showing client side validation fail message. Rather it submitting the form and then showing ...
Md. Shafiq Hossain's user avatar
0 votes
0 answers
401 views

Uncaught TypeError: Cannot read properties of undefined (reading 'messages') (forms AJAX POST)

Here I have created a custom module, which has one form in it...An ajax response is called when an Email is entered in form field and it will callback an HTML response. I have tested this code on my ...
kankari avinash's user avatar
1 vote
0 answers
27 views

Allow access to Webform form URL only through Ajax

I'm using Webform to create some forms, those forms must be showed in modal through Ajax, and all of this is working good. The issue is that I need URL to the form in order to load the form in modal, ...
mixerowsky's user avatar
  • 1,581
0 votes
1 answer
54 views

Showing parts of ajax-enabled forms in Dialog and using submit buttons in Dialog to change the form?

I'd like to achieve the following (d10): In a form a list of custom drupal plugins will be displayed. Each of those plugins has a settings form array depending on its type that will be merged into the ...
witti's user avatar
  • 171
0 votes
0 answers
164 views

Using StreamedResponse for AJAX?

I am looking for a way with a Form API form in Drupal to have an #ajax event on a form field. When submitted, this calls a remote API. How can I stream the response out to the screen without the ...
Kevin's user avatar
  • 27.8k
0 votes
0 answers
51 views

Commerce 2 - switch variation ajax error

I'm building a commerce site, one problem that I have is that the variation switch that works with ajax is having problems on the production server. I have analyzed the network tab of DevTools, the ...
felipep's user avatar
  • 332
0 votes
0 answers
24 views

When "Use AJAX" is set to Yes on a View with Better Exposed Filters, the old search results are not cleared

Using Drupal 8, when AJAX is enabled on an exposed filter old search results aren't removed. I don't see any console errors but it seems that 'Use AJAX' isn't clearing the div before loading the next ...
user110190's user avatar
0 votes
0 answers
76 views

How to change markup of modal dialogs

A modal form is defined in openModalForm(), and the modal form is called by $form['open_modal']. public function openModalForm() { $response = new AjaxResponse(); // Get the modal form using the ...
shibasaki_stack's user avatar
0 votes
1 answer
98 views

Error when trying to retrieve a term with ajax

We are creating a custom form to edit a certain node. We do this above because there are some things that cannot be accomplished with the default form. I want to use AJAX to populate the fields of the ...
shibasaki_stack's user avatar
0 votes
0 answers
893 views

How can I resolve the "Unique file URI" when using managed_file field in form API with a file name that already exists?

I am facing a strange issue with a managed_file field in my Drupal form API. Whenever I upload a file and save the form, and then come back again to upload another file with the same name, I get this ...
Zuhair's user avatar
  • 276
0 votes
1 answer
313 views

When a custom form is displayed in a custom template, ajax does not work

What I want to do I want to display a custom form with a custom template and use ajax in it to change values in the form. Problem Custom template notation prevents ajax from working. I didn't change ...
shibasaki_stack's user avatar
0 votes
0 answers
31 views

Report comments / Workflow

I am trying to implement a functionality that would allow authenticated users to report comments on a forum post. My first thought was to do it using workflows but comments dont have a workflow ...
ShadowAce's user avatar
0 votes
1 answer
113 views

trigger('RefreshView') problems with pagination

Colleagues, can you please advise: there is a views with enabled ajax and pagination, there is a form on the page (also ajax, but not views), which makes changes to the displayed views values. To ...
Mayk RE's user avatar
0 votes
1 answer
173 views

Use AJAX On Node Add Form To Change Field Required Status

On a node/add form I have a pair of fields that need to be able to control one another. The first field allows a user to enter a birthdate, the second field allows the user to say the birthdate is ...
Drupal Learner's user avatar
0 votes
1 answer
935 views

How to redirect custom ajax form to external url with headers

When setting the form with ajax handler like this public function buildForm(array $form, FormStateInterface $form_state) { //... $form['actions']['submit'] = array( //... '#ajax'...
Viswa's user avatar
  • 13
1 vote
0 answers
23 views

Focus Returns to Field With AJAX Callback [duplicate]

I am attempting to complete several AJAX commands based on the value of a field in a node/add form. The commands themselves work. However,when a user is filling out the form the cursor (focus) keeps ...
Drupal Learner's user avatar
1 vote
1 answer
253 views

How do I debug A block ajax issue on a custom theme?

I'm receiving and ERROR " An error occurred while attempting to process /views/ajax?_wrapper_format=drupal_ajax: ajax.$form.ajaxSubmit is not a function" when clicking on link in views block ...
Vitaliy K's user avatar
  • 129
0 votes
1 answer
197 views

Add a text field value with AJAX

Problem: After an AJAX callback, the text is not inserted in the body field. Description: I created a fresh Drupal installation. Added a field 'Type' | field_type | List (text) to the Article CT. The ...
rfmarcelino's user avatar
0 votes
1 answer
302 views

Dynamicaly add ajax form item and add event on checkbox

I've added an ajax callback to my form to add some data on it : $form['add'] = [ '#type' => 'button', '#value' => t('add'), '#ajax' => [ 'callback' => [$this, '...
lobafox's user avatar
  • 103
1 vote
1 answer
437 views

Problem with Adding new fields with Ajax call to a custom form

I have a simple form where I am trying to add a couple of fields to it when the user clicks a button using an ajax callback. Here is what I have: public function buildForm($form, FormStateInterface $...
Akbar Bakhshi's user avatar
1 vote
0 answers
59 views

Node edit form - Is it possible to load entity reference field data on click after the form has finished loading?

I have a custom node type (let's call it Project) with many fields. Three of these fields are of an Entity reference type, referencing other related nodes (let's call them Project Attachments A, B, ...
S.Gou's user avatar
  • 11
0 votes
0 answers
83 views

Ajax call brings all the Javascripts of drupal ruining the original page javascript

Based on this solution https://www.drupal.org/docs/7/api/javascript-api/simple-drupal-ajax-load-with-jquery-and-delivery-callback I'm brining with an ajax call, a multistep form. The ajax brought ...
MMT's user avatar
  • 41
0 votes
1 answer
65 views

Node form field validations on change with AJAX

I'd like to be able to trigger the validations for a field, including relevant entity constraints, on a change (or equivalent) event for the field using AJAX. But I cannot figure out how to make that ...
brad.bulger's user avatar
0 votes
0 answers
259 views

Cookie value causing a "Uncaught Error: Call to undefined function menu_get_object() " error

There are plenty of posts regarding this Drupal error, but my situation is quite odd indeed. Here's the background: I was asked to investigate an ajax error popping up on a form which does an account ...
user1015214's user avatar
  • 1,811
1 vote
1 answer
128 views

Why is ScrollTopCommand not working?

I have a node edit form which I submit via ajax and then opens a modal doing this: $form['actions']['submit'] = array_merge($form['actions']['submit'], [ '#value' => t('Get quote'), '#...
liquidcms's user avatar
  • 1,248
0 votes
0 answers
95 views

Why is Admin Toolbar preventing modal from opening?

I posted this a few weeks ago: Why doesn't form submit callback get called? and with @4k4's help was able to get my custom form opening a modal when the form was submitted (see answer posted there)...
liquidcms's user avatar
  • 1,248
0 votes
0 answers
92 views

Callback Not Firing On Change

I am somewhat new to Drupal development. Please bear with me on this. I am trying to create a popup after a user enters a value in a date field on a node/add form. This is on a Drupal 9 site. To do ...
Drupal Learner's user avatar
0 votes
2 answers
289 views

Why doesn't form submit callback get called?

I have a custom page (controller) which embeds a node form. I want to submit this form via ajax but also run another submit handler which opens a modal with some of the values from that form. My ...
liquidcms's user avatar
  • 1,248
0 votes
0 answers
159 views

Trying to populate one form select with another using Ajax, getting ajax.$form.ajaxSubmit is not a function

Building a custom module in Drupal 9.4.5. I need to have the user to select a country from one form select, and that would populate a second (states/provinces) using a form AJAX callback. It works ...
wheelercreek's user avatar
0 votes
1 answer
72 views

Impossible to use custom fields in twig linked to form

I have a form in which I have two date fields and a filter button. This form is included in a custom view in which I have a table that displays data from the database. The date fields are here to ...
Pedro's user avatar
  • 51
2 votes
0 answers
369 views

Refresh a form with Ajax after closing a Dialog

So I have a custom form in which I display a list of entities. Below that list, I added an “Add More” link which opens a Dialog. When I close (or submit) the Dialog, I want the list of entities to be ...
JFC's user avatar
  • 521
0 votes
0 answers
266 views

Action of webform displayed in modal opened by OpenModalDialogCommand in AjaxResponse

I'm trying to open a webform in a modal by using OpenModalDialogCommand in an AjaxResponse like this. in buildForm method, I'm specifying AJAX callback like this: $form['actions']['submit'] = [ '#...
Miloš Kroulík's user avatar

1
2 3 4 5
51