Questions tagged [forms]

Use it for questions about the Form API. Don't use it for entity or entity field forms.

Filter by
Sorted by
Tagged with
1
vote
1answer
28 views

Why ajax button calls submitForm?

I have no problems with using Ajax in every form element other then button. When I'm clicking this button '#type' => 'submit', '#ajax' => [ 'callback' => '::ajax_function', '...
0
votes
0answers
10 views

Theme suggestion for commerce-cart-form input--submit buttons [duplicate]

I have a Drupal Commerce cart view (overview of the cart). In the form 3 buttons are rendered. delete-order-item button update list button checkout button I want to create 3 specific theme ...
4
votes
1answer
1k views

Ajax pager with form callback

I created a form using the form api that outputs a list of results via an ajax callback. I want the said view to paginated. How can i do that? I'm using drupal 8 and don't want to use embeded views.
2
votes
3answers
1k views

how to make a form field be required with hook form alter

I want to alter a form to make the revision log be required. with drupal 8, I am adding this in a module $form['revision_information']['#required'] = TRUE; but the field does not become required. ...
5
votes
4answers
3k views

tableselect with dropdown per row

I use a tableselect to output a list of terms and per row I want a drop down (select): $header = array( 'name' => array('data' => t('Name')), 'weight' => array('data' => t('...
0
votes
2answers
25 views

Hide one form element until another is selected

Is there any way to disable the field 'model_article_nr' until 'model' is selected this is what i have and as it is now i can select 'model_article_nr' before i have choosen a model which leads to ...
0
votes
1answer
396 views

Prevent redirect after submitting the form

In Drupal 7 profile2 module, want to make profile2 edit form to stay on the form itself after clicking SAVE button. With the following code, it stays on the form itself and displays the values ...
0
votes
1answer
408 views

Form submission confirmation popup ( a variant of ) [on hold]

I have a lengthy node form. When the user clicks 'Save' I want them to be asked a further question which causes a flag field to be set or unset. For instance upon node form submission the user is ...
1
vote
2answers
839 views

form_get_errors() is NULL when calling it in an AJAX form callback

I have a form with a bunch of required fields that all have the same callback. Here's a single field example: $form['name'] = array( '#type' => 'textfield', '#title' => t('Name'), '#...
0
votes
0answers
27 views

How do I allow authenticated users to remove their resume file from their user profile? [on hold]

I am using Drupal 7.67 instance with CiviCRM integrated. Authenticated Users on my website are able to upload Resume to their user profile. However, they aren't able to remove the resume or replace ...
0
votes
0answers
21 views

How can I override the form-element-label.html.twig template?

In a view, I have checkboxes displayed using the better-exposed filter. Ajax setting is true. Currently, there is no template suggestion for overriding form-element-label.html.twig. Somehow by adding ...
0
votes
0answers
12 views

How to target daterange field in form alter?

I have a date range field in my exposed filter and I want to add a class on it. The problem is that I can't target it despite I can do it for the rest of the field of the form.How can I achieve that? ...
2
votes
1answer
1k views

Customized User Registration form with Profile fields

I'm missing something core to how user registration forms are customized and the data is added to the database and I'm hoping to get a workflow. I have created about a dozen Profile fields, textareas,...
0
votes
1answer
1k views

Trigger ajax callback from input field webform

I have a form build with the webform module. When text is entered in the input box in this case webform component 2 I want it to execute a ajax function and put data in a div. However this is not ...
0
votes
1answer
349 views

How to make uploaded file permanent to node without node submit

My module automatically save new empty node when user create new node and redirect to edit this node. Now, is it possible to make uploaded file on _node_edit form without submitting form? edit: When ...
4
votes
2answers
3k views

How to trigger a form and pass variables to $form_state with jQuery?

What is the way to trigger a Drupal form via JavaScript, and pass new values to $form_state while doing so? I have a main form, which has an element that triggers a jQuery UI dialog with a form in it....
1
vote
2answers
2k views

Entity form with pre-populated entity reference from URL

I have two entities which are in a parent/child relationship. Now I want to add a operations link in the parent's list view so that I can show the child's entity form with the reference to the parent ...
1
vote
1answer
24 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
1answer
1k views

Skipping form validation with a custom action button

Related to my previous question -- I've got the button added to the form properly (thanks googletorp!), but now I'm having separate validation issues beyond just adding the button. I have added a "...
2
votes
2answers
890 views

add css if url contains

I have one node type and two page types for this node. http://site.com/themes/* and http://site.com/years/* And i want to hide one of the "view-filed" in all "years" pages using the css. Found ...
0
votes
1answer
405 views

How can I remove “please wait…” from a form?

I saw this Remove the "Please wait" text on Ajax Call but I can't find the form element. <?php dsm($form);?> and <?php dpm($form);?> return errors. This is what I found in $node: ...
2
votes
2answers
365 views

Configuring mail function in multistep form submit in drupal

I have been working in a multistep customer-survey form and i am unable to configure and send mail after the form is successfully submitted. Here's is code for submit handler, function ...
4
votes
1answer
839 views

How to set a default value for Simple hierarchical select?

I tried to implement hook_form_alter in order to pass default value to Simple hierarhical select views exposed filter. function mymodule_form_alter(&$form, &$form_state, $form_id) { $tid = ...
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 ...
5
votes
1answer
2k views

Creating date field with only month and year

We are using the form API in a custom module (and not an entity field), how can we easily set the date widget for just year and month data entry. I've tried adding a #date_format attribute but no ...
1
vote
2answers
777 views

Form built by Ajax commands not sending values

My problem has to do with Ajax commands and the form being rebuilt after calling ajax_command_append(). I have a form with two elements an option and a textfield. These are built-in with the form on ...
0
votes
1answer
410 views

User registration silently fails - how to debug?

On our Drupal 7 site, user registration silently fails. Drupal doesn't even reach the form's validation functions. What we checked: disabling javascript didn't help. Removing installed modules ...
0
votes
1answer
424 views

how to save checkboxes values in node programmatically

i want to save checkboxes values in entity reference checkboxes field with node_save : $form['wrapperrr']['id_offre'] = array( '#title' => t('Liste des Offres'), '#type' => '...
0
votes
1answer
2k views

Making text fields autocomplete in views exposed filters

I want to make a text field auto complete in a views exposed form. I tried using the following code but nothing happens(I don't see that blue icon in the text field): <?php function nk_menu() { ...
1
vote
4answers
788 views

Create duplicate registration form with extra fields

I have a site built using Drupal 7. The site has a registration form now. There is a new requirement to add a couple of new fields in the registration form and put it in a new page. http://example....
1
vote
2answers
917 views

Webform Custom-Field Module and validation

I am currently working on a Webform that is used to enter some rather complex finance information (think tables with sums and other weird checks). Since the styling has to be rather specific for this ...
0
votes
1answer
683 views

Save checkboxes value into another checkbox field

I'd like to save the value of a checkboxes field which is link to a product once I save my content type. I've created the code needed to create the product and the node. When the node is in creation ...
2
votes
2answers
983 views

Need to force #default_value for AJAX tableselect checkboxes

I built a drop-down ajax pager that replaces a tableselect with the requested page of rows. The array of selected item IDs is stored in a hidden field and that logic is working across entity load/save ...
1
vote
1answer
28 views

How to disable htmlspecialchars in custom module form table?

I'm making a table form $form['table'] = [ '#type' => 'tableselect', '#header' => $header, '#options' => $this->getOutput(), '#empty' => t('No vehicles found'), ]; In ...
0
votes
1answer
366 views

How do I display a summary page after finishing a multistep form?

I have a multi step form in Drupal 6, and I want to show a summary page based on entered information in the steps after finishing the steps and user click finish button. I am using the ctools wizard ...
2
votes
1answer
431 views

AJAX form submission

I am doing an ajax form submit, Issue #1 : I am facing problem while submitting the form, The form have a submit and a validate function. In the validate function it is checking whether the username ...
0
votes
1answer
361 views

TinyMCE not appearing on custom form

I am creating a custom form and have run into a problem. I'm using the WYSIWYG module and for some reason the text areas on this custom form don't show as rich text editors (tinymce shows on other ...
4
votes
3answers
522 views

using form_state->set() inside ajax callback but cannot get the value back outside the callback

I want to add some arbitrary variable to store it in the form_state and use it again so in one of my ajax callback functions I set a property named var: public function MyFunctionCallback(array &$...
2
votes
1answer
342 views

I can't get the og_group_ref set in a node form rendered via a custom block

My block code is as follows: mymodule_block_info() { $blocks = array(); $blocks['my_contenttype_form_block'] = array( 'info' => t('My CustomContentType Add Form'), 'cache' => ...
0
votes
1answer
765 views

Form Validation. Ensure Placeholder is not submitted value

I have a Drupal registration form with a placeholder set on a first name field. I am trying to get the form to check so that if the placeholder value is the same as the submitted value it will give an ...
3
votes
3answers
875 views

Dynamically add input field using #ajax

As the question says, im not clear on how to go about adding new input fields depending on values of certain fields in the form. I got as far as setting a callback and a wrapper, but i just can't ...
1
vote
2answers
734 views

Change the file field description

How can i change the file field description without hacking a contrib module like the file.field.inc file ? this is the function i would like to modify: theme_file_upload_help
1
vote
2answers
750 views

Theme a node form [closed]

I'm attempting to theme a node add form for my new slide show content type in D8 using an example for D7 that I found here, but I'm not having much luck. I've made and enabled a module named ...
0
votes
1answer
433 views

Populating select list from a taxonomy term field

I'm trying to populate a select list dynamically by pulling its values from a taxonomy term field linked to the current-user account. Just to clarify, below function is a hook defined by a module that ...
3
votes
1answer
68 views

is it ok to use system_check_directory in a custom module?

I love the easiness of applying system_check_directory to a form field. You just add '#after_build' => array('system_check_directory'), to your field definition in a form and it does it all : ...
1
vote
2answers
1k views

Ajax submission leads to => An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (2 MB) that this server supports

So i'm trying to submit a form using ajax, in my form i have the following: $form['actions']['#type'] = 'actions'; $form['actions']['submit'] = array( '#type' => 'submit', ...
0
votes
1answer
29 views

How to get the form field label of a multi-value field

In hook_form_user_form_alter I need to get the title of each field. When I dump a normal (single-value) field #title is an array value, like this: array (size=13) '#title' => string 'Name' (...
0
votes
1answer
762 views

Form validate without submit action

I'm developing a site that it will use Services for the CRUD operations and ANGULARJS for the comunication frontend <-> backend. Now when I want to insert a new content of content type FOO I will ...
2
votes
1answer
74 views

Drop UserMailRequired constraint

In my Drupal site, only administrators create users. And users are created without an email. Users can edit themselves some of their account fields, but the email is not one of them. But the user ...
-1
votes
2answers
755 views

Back button in multistep form

I am facing an issue with the Multistep module in Drupal 7. I used a custom module to build a session_store multistep form with the help of the mforms_example module. Except for the ...