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.

0
votes
2answers
14 views

How can I remove the checkbox from tableselect form header only?

How can I remove the checkbox from tableselect form header (Drupal 7) only? I am looking for any configuration if available that can be applied in the below sample code: $form['listings'] = array( ...
1
vote
1answer
56 views

How do I add an autocomplete to a form element that is not an entity reference?

I need to add a auto complete text field in my custom form module. The auto complete values should be retrieved from the database table. Can anybody tell me how to do that?
0
votes
0answers
14 views

How to access the value from select form?

I have created a form with one field of "select" type. Whenever the user selects an option, I need to append the URL with the #options key. My form looks like this: $form['language'] = array( '#...
0
votes
0answers
27 views

Programmatically Alter Billing/Shipping Address form

I am using Drupal Commerce 2.11 and Drupal 8.6.9. I need to make a simple edit to the address forms in the checkout - changing the #empty_option of the "locality" select boxes. However, this is ...
0
votes
0answers
49 views

How can I use a controller to render a form in a template file?

I'm looking to add a form inside a custom template. opacsearchmodule.routing.yml opacsearchmodule.route1: path: '/form-test/object-builder' defaults: _form: '\Drupal\opacsearchmodule\Form\...
0
votes
1answer
39 views

Let customers set appointments while showing me their country time and my country time in contact form output [closed]

I'd like to create a form in which a customer will insert basic details like name, email and so forth but will also schedule a specific date and time in an appointment scheduling system, adjusted to ...
0
votes
0answers
10 views

How to add form to expiration options form

I am using the Commerce node checkout module (https://www.drupal.org/project/commerce_node_checkout). How would I add the form product array form to appear only when the expiration is greater than the ...
1
vote
1answer
21 views

Change checkboxes in a node edit form alter

I have a problem with an ajax function which doesn't work properly and I don't understand why. I done a similar thing long time ago in Drupal 7 and it seems I forget how it works. I have a node type ...
1
vote
1answer
35 views

Custom submit button text

I have a classic contact form. I can add for example some custom placeholder like this : function my_theme_form_contact_message_about_your_project_form_alter(&$form, FormStateInterface $...
3
votes
1answer
72 views

How do I avoid caching a redirect response from a form?

I have a Drupal 8 form used by authenticated users which sometimes needs to redirect based on the presence of absence of something in session. I don't want the redirect to be cached. My form is ...
-3
votes
1answer
48 views

How to submit form selecting an option in a <select> defined in inline_template?

I have this custom form in which there is this: The corresponding code: $form['actions'] = array( '#type' => 'details', '#title' => 'Tâches associées', '#open' => TRUE, ); $...
1
vote
1answer
37 views

How do I download a dynamically-created file in a form submission?

I've got a form that builds an array of data. On submission, it updates a table displayed in the browser, using AJAX; that works fine. I want a second submit button that downloads the same data as a ...
0
votes
0answers
36 views

Limit validation errors on ajax change and autocompleteclose

I have modified the node add and edit form for one of my custom types, adding a few ajax callbacks: a couple are on the onchange values of text fields, one on the autocompleteclose of an autocomplete ...
2
votes
1answer
37 views

How to have the autocomplete option with ajax in a text field?

I am struggeling with creation of tetxfield with autocomplete option for my Drupal 8. My Drupal website is multilingual, and on one view page we present some content in Default language, by typing in ...
0
votes
1answer
16 views

How to grab $form_state value from text-format from drupal form

I created a form for my module. I have a formatted text box $form['message'] = array( '#type' => 'text_format', '#title' => 'Body', '#format' => 'basic_html', '#default_value' => '<p&...
0
votes
0answers
29 views

Form Builder Table Column Weight

I am trying to create a table in a Drupal 8 form and would like to set grid-based column width similar to Boostrap or any other front-end framework, i.e. each column should have a weight out of 12. ...
-5
votes
2answers
50 views

How to create a custom login form [duplicate]

I need to know please any suggestion about how to create a custom login form for another type of users in drupal 8 , I have now /user/login is for administrator, but I need to add /account/login it's ...
1
vote
1answer
190 views

Controlling a dependent field in a multi-instance paragraph

The fields below are part of the node/add node/edit forms of my custom node type. The paragraph field_para_city contain one field_city. (I later need to add other fields in the paragraph). The user ...
0
votes
0answers
19 views

Form in ctools modal not submitting

I have a form (table with checkboxes) created using theme_tableselect. The form is appearing fine with checkboxes. I need to show confirmation popup/modal before processing the checked rows. I am ...
0
votes
1answer
28 views

How can I use postsave method extending WebformHandlerBase for submitting to account fields [closed]

I created a webform handler class extending from WebFormHandlerBase: The method, postsave has the following code: public function postSave(WebformSubmissionInterface $webform_submission, $update = ...
0
votes
1answer
41 views

How to create entity within blockForm?

I would like for users to be able to create new paragraph entities within the form of a custom block instead of going into the linked content type and adding the content. In the past, I've always ...
0
votes
0answers
33 views

How to get referencing parent entity when adding entities via Inline Entity Form to set automatic titles?

I have a content type "Parent" and a content type "Child". When adding Parents, the user can add Childs via Inline Entity Form. Child content types have Automatic Entity Label enabled. In that ...
1
vote
0answers
20 views

entity_autocomplete for custom entity

There is the entity_autocomplete field type which I expect should just work for core entities. I have created my own entity using Drupal console and would like to query those entities with an ...
0
votes
0answers
67 views

AJAX on Select Element throws: The specified #ajax callback is empty or not callable

The Problem: I have 5 select elements in my form, all are linked to their own ajax callback. Each select element has the same wrapper because the whole container should be updated when any of the ...
2
votes
1answer
30 views

How can I process a node form from a custom submit handler?

I have a use case where I have a custom submit button on a node edit form that will take the user off to another page to do some other editing. If the user has made some changes to the node, such as ...
1
vote
1answer
30 views

Get delta of parent form field widget

I've got some form input fields in a paragraph whose visibility need to be dynamically toggled by the value of a another field. This can be done with the states API and the ...
0
votes
1answer
33 views

Form alter overriding submitted values

I have a form_form_id_alter function that sets some default values and a checkbox checked. If I submit the form, with the checkbox unset and it fails validation, the re-rendered form re-sets the ...
2
votes
2answers
48 views

Automatic username generation from name fields at registration

Drupal core 8.6.5 I am trying to change the user registration process to omit the username field and generate the username from the first name and last name. Since I am new to Drupal and want to ...
0
votes
0answers
10 views

How to clear the publish checkbox in form or form element validation

I have a D8 form where when a test involving the value of other fields fails, if the publish (field = status) checkbox has been checked the validation should fail and the checkbox should be cleared ...
1
vote
0answers
38 views

How can I add a property definition to an existing field?

I have a file reference field FileItem that has a display and description property but I want to add an extra one. I was hoping I could just override the default widget but I can't use this to store ...
0
votes
0answers
50 views

Form action as controller method?

I'm trying to fix a form that was created using a twig template. The form was not working because there was no action, nor was the form created using FormStateInterface. It's just a block that is ...
0
votes
1answer
61 views

Altering Views Exposed Form Elements and their Associated Labels

I have a series of Views Exposed Forms across a Drupal 8 website. My goal is to generate unique template suggestions so I can theme each individual input and their labels differently as needed. Here ...
1
vote
1answer
25 views

Add another button removes the default values from my fields on node form

I have a node form on which two fields are displaying. One is a list of radio buttons which is required field. I am getting a value from url using arg(3) and setting the default value of that field $...
1
vote
1answer
20 views

Programmatically disable content translation options in content edit form

I want to programmatically disable the content translation options located at the bottom of the content edit form (see yellow area in screenshot): I know that i can disable the revision information ...
1
vote
0answers
46 views

Validate a field only if the value has changed and/or if it is a new value

I'm building a module that get information from the NCBI database API -- specifically it get's publications, from my group, by using a publication ID. I want anyone in the group to be able to add a ...
0
votes
0answers
14 views

Upload file using File type=“managed_file” disappears immediately when clicked on upload?

I want implement upload zip file using FORM API where I want to show the progress bar for uploading file so I have written code like: $step2['browse']=array( '#type'=>'managed_file', ...
0
votes
0answers
31 views

Embed user edit form in a block

I am trying to embed current user edit form in block. Actually I want just to embed some of the newly added fields. I tried to follow this code: Embed some user profile fields in a block form But I ...
0
votes
1answer
82 views

Webform Submission Using Rest API POST method

I just created the webform and added fields. I need to create a Webform Submission Using Rest API POST method. I just installed Rest & Rest UI modules for this. But when I try to test my API ...
0
votes
0answers
15 views

Proper Schema file for integer and select

We have a custom module, mymodule that has an admin form where it stores field of type: number and select. I need to create a mymodule/config/schema/mymodule.schema.yml file, but don't know what to ...
0
votes
2answers
35 views

Form multiselect item and url encoding with GET method

I have a form on a Drupal 7 site, which is submitted using the GET method to refresh the page's display using the query parameters. One of the parameters uses the select box, with the multiple option. ...
0
votes
1answer
27 views

Turn form builder response into HTML

I have a node type called "competition". I can get a form for it like so: $values = array('type' => 'competition'); $node = \Drupal::entityTypeManager() ->getStorage('node') ->create($...
0
votes
0answers
51 views

$form_state->setError not working for add_more buttons

I am altering a paragraphs form to add a validation function to the "Add More" button using this code: [This button add widgets for multiple value fields] function ...
0
votes
1answer
69 views

Getting form variables data into twig templates

I need to pass an array to twig along with the form. public function buildForm(array $form, FormStateInterface $form_state) { $form['job_locations'] = $job_locations; $form['#theme'] = '...
0
votes
0answers
17 views

Index Form API forms with Solr search

My site uses Apache Solr search and Apache Solr Multisite Search. I need to be able to index some Form API forms created in custom modules so that they return in search results. For instance, when a ...
0
votes
1answer
73 views

How do I enable an onclick event in a link on a form?

I am using the following code. $form['test'] = array( '#type' => 'link', '#href' => "javascript:;", '#title' => t('Show'), '#attributes' => array( ...
0
votes
1answer
36 views

Prevent underscores from removing text?

Drupal seems to be removing all text prior to an underscore in my form. This is in the Form.php file of my module implementing Google CSE, so I cannot change the attribute name. if (array_key_exists('...
0
votes
1answer
26 views

Hiding group_group field programmatically

I am trying to hide the group_group (request membership) field for organic groups based on a radio button. Here is what I have done that doesn't work: /** * Implements hook_form_alter(). */ ...
0
votes
0answers
9 views

Ajax Form “back to form” link not reloading form via ajax

This just started happening today. We have a site form that built with 'Ajax' turned on. The form submits, and ajax displays the 'confirmation' message with the 'back to form' link. When clicking '...
0
votes
0answers
39 views

Fieldset collapsed by default

I'm working on a Drupal 7 project where I use the form API to build a form. I want my form's fieldsets to be collapsed by default. I use the following code: $form['fieldset'] = array( '#type' =&...
0
votes
1answer
26 views

Webform Validation Allow Lowercase Only

I have an email field in a webform that will trigger a rule that checks against that field against a user's email. The issue is, rules is case sensitive so if the webform field had capitals, and the ...