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 [forms]

Don't use it for entity or entity field forms.

1
vote
1answer
779 views

how to validate minimum age in webform

I've got a question about webform and webform validation. I'm in D6.19 with webform 6.x-3.4 and webform validation 6.x-1.3 I'm adding a date field to capture age, and I need to validate that the age ...
0
votes
1answer
581 views

Redirect to Continue Multi Step Form

I am building a form that can either begin on the home page or at the '/apply' url. I used this tutorial to build the multi-step form. The form works great if I start from '/apply' and begin at the ...
0
votes
1answer
342 views

How reset $form_state on ajax call for get real value in submit?

I have see some post about that,but i still have no real answer. In my form, user can select a register address in a select field. When he select an address, the ajax set value on some other fields : ...
1
vote
2answers
20 views

Set a multiple field value on a form

I use this field definition in the entity "message" class. $fields['fichier'] = BaseFieldDefinition::create('file') ->setLabel(t('Fichier attaché')) ->setSetting('file_directory', '...
0
votes
2answers
645 views

How do I theme the contact form?

I am trying to create a contact form for users with username, email, message, and submission button, but I want to customize the structure of the form. Where do I get the structure of the form to ...
1
vote
1answer
669 views

Redirect to Different URl on validation errors in form builder

I am using drupal 8 fapi and i have user case as below I have a form on https://example.com/landing-page and I submit the form and there are validation errors .the page should reload as https://...
0
votes
1answer
342 views

How to check if an edited form is editing a translated node

I have a content type named film. Original language of a film is FR. Let say I have 2 translatable fields on a total of 10 fields in film. I am using this code to alter the add/edit form of film: ...
0
votes
2answers
873 views

Ajax error on node form edit page

I'm trying to ajaxify part of node form. I have a hook_form_alter that adds extra ajax property to a widget of select field. The problem I'm facing is the callback method / function, which is not ...
0
votes
1answer
31 views

D8 Custom submit handler does not appear to be being called [on hold]

Can anyone tell me why my custom handler is not being called when I save a new entity please, Im using D8.7 Thanks use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpFoundation\...
0
votes
1answer
1k views

Captcha session reuse attack detected error message in form with anonymous user

I am experiencing a problem with the Captcha module 7.x-1.3 version (under Drupal 7.39) I don't use webforms My form is a simple Contact form My form does not contain any AJAX field My form does not ...
2
votes
1answer
389 views

Submitting a form causes 'secure connection failed' error that persists

I've got a SSL certified server running drupal 7.37. Everything was working fine until I started adding form submission to a module I'm working on. As soon as I submit the form, I get 'Secure ...
0
votes
3answers
2k views

How to set validation error for specific subfield of the paragraph type?

I've got paragraphs type with two fields which I've added as a field into my vocabulary. I've added validation function (#validate) into $form using hook_form_FORM_ID_alter where I'm validating ...
5
votes
5answers
4k views

How do I send a variable value from my form to another page using the POST method?

In the first page I have the following code: $form['message1'] = array( '#markup' => $this->t('Check Your Details once again !!'), ); $form['candidate_name'] = array( '#type' => '...
0
votes
2answers
629 views

Views VBO: Set custom action with custom attributes selected in form

I have a view of persons. I like to add the persons to an event. I also like to set the status of the resulting relation to one of the values "optional" or "required". Therefore I use VBO on a list ...
0
votes
0answers
21 views

Get input label on input.html.twig file

I'm working on an input.html.twig file. I need the label name of the input for class and other reasons, but for some reason, I can't figure out how to grab it. I thought it would be part of the twig ...
-3
votes
1answer
31 views

how to Get values from protected array [closed]

i want ids which is in protected selection array . function prevent_deletion_form_alter(&$form, FormStateInterface $form_state, $form_id) { switch ($form_id) { case "...
0
votes
0answers
7 views

Ckeditor with programmatic text_format field

I have ckeditor installed on my site, and when I use filter formatted textareas on my website where admin pages or fields were created using the UI, the ckeditor replaces correctly. When I use the ...
0
votes
2answers
837 views

Loading a form from a form include file in a module

I have an external form that needs to be loaded inside a template file, used by a block. Right now, i'm a bit confused as to how to load this .inc. Looking at the API docs point to module_load_include(...
2
votes
1answer
46 views

on submit does not allow login to occur [closed]

When I add an additional "onsubmit" function to the login button, the login doesnt continue this is my code function xxx_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $...
0
votes
1answer
770 views

How to add markup inside a form radio button div

Currently I have a form displaying radio buttons and I added some markup to it by attaching #suffix to the form element. However, I found that this didn't do exactly what I needed. This created the ...
2
votes
1answer
614 views

How do I change the ID of a copy of an exposed filter?

I'm using answers from Expose a view's filters both in a block, and in the actual view to duplicate an exposed filter as a block and make it appear in another region on every page. I want to ...
2
votes
2answers
1k views

How to close the overlay after form submission

In order to be able to quickly edit Fullcalendar items, I altered the node edit form of the specific content type so the events are saved with AJAX and the page doesn't have to reload. However, I don'...
0
votes
2answers
636 views

How can I dynamically disable a single required field from validation in a form?

This is an extension of this question: Need help with AJAX callback function for text field validation in form_alter I have a form with a Username autocomplete field (txn_user). The editors want to ...
0
votes
1answer
359 views

How do I add a date picker that is rendered from most the browsers?

I am migrating from Drupal 7 to Drupal 8. In forms I use '#type' => 'date_popup' for date fields, which Drupal 8 replaces by '#type' => 'date' and uses HTML 5. I'm finding it most ...
0
votes
1answer
724 views

Preventing users from registering with xxx@yyy format email address

Drupal seems to let users register with emails like xxx@yyy I heard that this kind of email address can exist. But I want users to register with only emails like xxx@yyy.zzz Is there any way to ...
1
vote
1answer
1k views

Show modal modal message on form success

I have a custom form that submits via AJAX. On form error, i simply return the whole form on my callback function, and the HTML is replaced, but i want it to open a modal dialog on success. What is ...
1
vote
1answer
349 views

How to extend a specific node type form?

I am searching a way to overwrite the NodeForm to get a class per bundle. Actually EntityForm manages the form for all entities. NodeForm extends it and manages the forms for all nodes. I wrote a ...
4
votes
1answer
664 views

Prevent dual submit on form submission

I've got a form that submits via AJAX and in the callback I need to rebuild certain parts of the page to reflect the newly submitted data. One of these parts is the form, which I need to clear all ...
0
votes
2answers
588 views

Add class to all labels in a comment form

Pretty straight forward. For every label within a comment form, I wish to add a particular class to it. Using only functions in template.php, in Drupal 7, how can this be done? If it can't be done ...
1
vote
2answers
68 views

How to call a function in a form from another form? [on hold]

I have 2 forms: distribution_inscription_table_form and distribution_inscription_for_user_form in the same custom module (amap). namespace Drupal\amap\Form; use Drupal\Core\Form\FormBase; use ...
2
votes
1answer
3k views

Validating node creation / edit form

I'm using form_alter to play with the node form for a specific content type. This content type has many different fields and I'm also using Field Collection module to organize all these fields & ...
0
votes
1answer
846 views

Inline Entity Form validation

Created a content type and add taxonomy form in it using Inline entity Form module. So, the rendered taxonomy add term looks like : What I want to do is ADD CUSTOM VALIDATION to the "NAME" field. I ...
1
vote
1answer
5k views

Create a form programmatically and display result on template

I'm trying to create a simple page with a form. With the different filled fields I want to execute different EntityFieldQuery in the HOOK_form_submit. To finish I want to display the result of ...
0
votes
0answers
14 views

How do I use the DateFormatter? [duplicate]

I am trying to use the DateFormatter so I can convert my unix time-stamp into a usuable date stamp that will be set on a custom form. This is my code: $time = \Drupal::time()->...
4
votes
1answer
382 views

How to limit what is available for a role in Administration menu ?

I am using Drupal 7 and installed the Administration menu. It works fine and I am really happy with it but after creating a new role, and also creating a new user for that role, he seems to have the ...
3
votes
1answer
22 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?
4
votes
3answers
3k views

Node add form alter & submit custom field

I have a content type "event" with a field called "field_pricelist". It's a dropdown with no values, I add the values when I alter the form. The values come from a custom table (install / schema) in ...
1
vote
1answer
1k views

How to retrieve a select box option and set the field's value to it?

I have a a taxonomy term select box (called "product_keyword") in a node that gets its options populated via the Reference Field Option Limit module. There are 3 other taxonomy term reference fields ...
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
2answers
22 views

Search Nodes by reference field target ID

I have a Node by the Project bundle name. Each Project has a reference field to another entity by the name of Contact, that this contact entity has the Client bundle. I can get the Client target ID ...
0
votes
3answers
2k views

How To Hook To Commerce Checkout Button?

I need to add a custom function to the Confirm Order button on a Commerce Checkout form. I can't figure out how to call it. The button id is "#edit-continue' and its displayed text is 'Confirm Order'. ...
2
votes
2answers
1k views

Is this the proper way to add a 'class' attribute to a form date element

$form['stop_date'] = array( '#type' => 'date', '#title' => t('Stop Date'), '#default_value' => date("Y-m-d"), // default to today '#id' => 'stop_date', '#attributes' => ...
1
vote
1answer
803 views

How I can intercept an image field upload and validate it?

I have a content type with an image field. I need to validate this field because I need to check if user upload a real image or only a file with image's extension (like jpg, gif, png etc). I have ...
0
votes
1answer
715 views

How can we achieve multiple forms in a single page?

I have menu callback which is getting called multiple times on the same page by an AJAX request resulting rendering the form with same HTML id $items['mymodule/page'] = array( 'page callback' =&...
1
vote
1answer
21 views

How to populate select field from View result like in

In a custom content entity, I have defined this field $fields['from_seliste_id'] = BaseFieldDefinition::create('entity_reference') ->setLabel(t('Offreur')) ->setDescription(t('Le SÉListe ...
0
votes
1answer
32 views

Exposed form don't have class attribute

In a form_alter, I simply want to add a class to an exposed form (this code works for a custom form) : $form['#attributes']['class'][] = 'my_class'; But neither my class nor the default class (...
0
votes
1answer
696 views

How to Fetch/Load a Node form using jquery/ajax?

In my previous question, I asked on how to fetch view blocks, now I would like to do the same with the node form but somehow this is the code that almost worked for me setTimeout(function(){ $('....
2
votes
2answers
2k views

How to store data in database with Form API?

I'm new to developing Drupal 7 modules, and I can't figure out why my custom module's form data is not stored in my database's table called 'media_skins'. I followed the info explained in Creating ...
1
vote
1answer
834 views

How to alter inline entity form fields on node edit drupal

I want to hide some fields of product reference on node edit. My purpose is to unset or set access to false for colors or price field of line item included in node as inline entity from in a content ...
1
vote
1answer
916 views

How to create an Enquiry form with ability to submit a collection of enquiries

I am building a new site which has a large selection of different products/services on offer, the information for each is shown in it's own node. If the user has interest in a number of these ...