New answers tagged

0

I found a solution to resolve my problem. After having readed several posts, i have decided to create a custom Ajax Command to open my files (pdf/csv). Create a custom command - link In my custom module, I have built the required files for this and call in my CallBack function this new ajax command ('OpenFileCommand') : $ajax_response = new ...


0

You can open a new window which can be achieved using javascript. Call function like below using on click method. You have to pass the URL to open and title for the window. function openWindow(url, title){ var left = (screen.width/2)-(700/2); var top = (screen.height/2)-(500/2); var win = window.open(url, title, 'toolbar=no, location=...


2

When you want to get the HTML of the table you must use the renderer service. In Drupal 8: $html = \Drupal::service('renderer')->render($form['table']); Or better, use dependency injection :) In Drupal 7: $html = drupal_render($form['table']);


0

I tried many different complicated approaches, before I found a much easier solution that suits my needs so I am posting this as a solution. I setup my prints View this way: Category is added as an exposed filter No contextual filter, no relationship Set the view path to prints/% Use AJAX: Yes I created a module and used hook_views_pre_build() to get the ...


1

There are many ways to solve this, you can take different approaches to the filtering part, the URL part, and the contextual part, and how they play together to get you to your goal. Here's one of the possibilities, probably the easiest route: This is solved by adding a Relationship for the category field, and then adding a Term "Name" Contextual filter (...


0

I finally found the solution on the Drupal forum. I put it here, maybe it will help in the future a novice who will be in my case. What was missing was simply a list of essential javascripts for anonymous users. It seems that at one time it wasn't necessary, but now we have to add them otherwise they wouldn't be loaded for anonymous users. So what I needed ...


0

For those ones experiencing the same case in Drupal 8, this is the equivalent solution: $user_input = $form_state->getUserInput(); unset($user_input['my_tableselect']); $form_state->setUserInput($user_input);


0

I would like to avoid using PHP session variables here since it is easy to get mixed with other forms. Especially if the user wants to keep this form open and tried to open another form. Instead of PHP session variables, you may try to change the logic and move your code to a validation callback for the whole form. And from there you can set form state ...


0

The core issue for this is Add AJAX support to fields using Dynamic Views Arguments via Tokens, but at the time of this writing the only option available without custom coding is Business Rules' dependent field functionality. However, there are still unresolved problems with multi-valued fields. See Multi-valued dependent child fields are not saved for ...


1

Is there any way to tell PHPCS that the function is an AJAX-callback (so that such warnings are generated)? Yes, it's as simple as implementing hooks except that instead of "Implements hook_", it starts with "Implements callback_". The only problem is that currently (August 2019) it is not supported by Drupal's PHPCS standard and you don't get any warnings ...


0

These kind of errors often happen when you have not attached the proper library to your form. So one thing to check is if you have $form['#attached']['library'][] = 'core/drupal.dialog.ajax'; in your form's buildForm().


1

What I ended up doing was: 1) add an hidden field to my form and populate that field with JS function polaris_drupal_cloudinary_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { if ($form_id == 'node_gallery_form') { // Add field to pass the number of images to be added from GalleryWidget. $form['...


0

Comment by @maria loannidou worked for me: <div class="ajax-progress"><div class="throbber"></div></div>


0

I have resolved it by commenting redirection code from hook_login and added redirection code related changes in ajax callback function itself. Here is my code. function setMessage(&$form, \Drupal\Core\Form\FormStateInterface $form_state) { $response = new AjaxResponse(); $current= \Drupal::currentUser(); if ($form_state->hasAnyErrors()) { $...


1

@Weri, I would avoid doing that, having just implemeted your suggestion and spent the best part of a day trying to fix another issue. The query alter you suggest also affects entiry reference when linking paragraphs to nodes. A node I was woking on had 80+ paragraph item before I added the alter. Once added I was unable to save the node. Removing/Commenting ...


0

I've always handled changing form values in the form build or form_alter function itself. I can't remember where I saw to do this, but I've never been able to alter the form in the ajax callback itself. Have your form trigger an ajax callback. This should return the form or piece of the form in question, like your test_result_with_button() function. When ...


Top 50 recent answers are included