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.

2
votes
2answers
341 views

How to add field to ALL webforms?

How do I add a field to all webforms? I have a website where I'm using webform for surveys and I want that on each survey there will be a field that is the same in all of the nodes/webforms. Thank you....
1
vote
1answer
561 views

How to copy select list value from a webform submisison into select list field new node?

This is the scenario: A webform with the following fields Question -> Textfield Category -> Select options (Listbox) Listing vocabulary HETCAT A content type Question with these fields Title ...
0
votes
0answers
11 views

Download a file and redirect to the form after batch operation

On submitting a form we need to run a batch process that writes to a CSV file. Once the batch process is completed we would like to download the CSV file automatically and redirect back to the form. ...
0
votes
1answer
17 views

Unset widget tab from media browser programmatically

Need to unset a widget tab from media browser based on the condition of media type supported by the field. Media types: Image and Video. For example, There is a field which references image media ...
5
votes
1answer
3k views

How do I load a form with a specific form display (form mode)?

On a custom page I'm trying to load an user edit form with a specific form display. I'm able to load the form however I can't figure out how to load the form with the specific display. This is what I ...
19
votes
6answers
20k views

How do I render a form?

What is the alternative to drupal_get_form('user_login'). in Drupal 8? I am using the following code in theme_name.theme, but it doesn't work. // Include namespace for userLoginForm. use \Drupal\...
0
votes
1answer
563 views

Computed value on multipage Webform

I have multipage webform. I want to compute the value of the component (Hidden -type) which is on the second page based on the data submitted on the first page. I'm using hook_form_alter and added my ...
1
vote
2answers
583 views

File Upload Field not working

I just tried to create a simple mandatory file upload field in a custom form like this: public function buildForm(array $form, FormStateInterface $form_state) { $form['#attributes'] = array('...
0
votes
2answers
2k views

How to use managed_file to upload many files

I'm looking for a way to upload many files by means of the managed_file form API element. I would like it be like while uploading for node where is 'add new item' button. How to do it?
0
votes
0answers
21 views

Provide autocomplete field with user's Display Name

Drupal core already supports autocompletion of username fields. However is there a way to provide autocomplete for user's Display Name? Since this is a virtual field, a database query with % like ...
1
vote
1answer
854 views

Programmatically load and submit the user form

I want to programmatically load the user profile form for a particular user and re-submit it without changing any of the existing values. The reasons are complex but I am dependent on gathering data ...
-4
votes
1answer
33 views

Calling Drupal Form from non-Drupal 3rd Party Website

I have an existing non-Drupal 3rd party site and I am trying to submit a form request to a site written in Drupal. For some reason, the request does not process. I'm not familiar with Drupal and would ...
0
votes
2answers
27 views

Get value of programmatically (form_alter) added fields at form submit

I'm altering a node creation form using the form_alter hook in a custom module. In this particular case, I'm adding an email field which is not part of the content type structure. At the node creation,...
0
votes
0answers
22 views

form : I need to prepopulate an entity reference multi value field depending on select list

I need to prepopulate an entity refence field depending on a list selection field. If the user select liste "administrator" then ajax need to prepopulate the field with users asssociated to this list....
2
votes
1answer
578 views

How to keep URL parameters on subsequent pages after a form is submitted?

I'm sending a referral form out to my email database and I've got it set up so that their email addresses get passed through and appended to the form URL like this: http://www.holbrooktravel.com/...
1
vote
1answer
19 views

Set value on a new term based on a vocabulary custom field

I want to set the value of a field of a term based on a custom field set on the vocabulary. Basically if the vocabulary promote_to_index field is checked I want to the field_index_page of the term ...
0
votes
1answer
565 views

Embed a form inside a modal

I have a modal in my form. $form['myid_print_preview_modal'] = array( '#type' => 'item', '#markup' => '<div id="myid_print_preview_modal" title="ID Preview"&...
1
vote
1answer
781 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
582 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
347 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
25 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
346 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
877 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
32 views

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

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
390 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
630 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
22 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 ...
0
votes
0answers
8 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
840 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
772 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
615 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
637 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
363 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
725 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
352 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
668 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
70 views

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

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
858 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()->...