Stack Exchange Network

Stack Exchange network consists of 174 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
0answers
9 views

How to send an email to an user after user account field is edited?

I created a paragraph field with "Title", "File", "Observation" and "Approved" (only mods and admin have acess to this field) and attached it to a user account. The user has acess to the form that ...
1
vote
0answers
20 views

Apply constraint conditionally

I've just started to use Drupal 8's Entity Validation API and I'm applying constraints to entities in the following way using hook_entity_bundle_field_info_alter: ...
1
vote
1answer
27 views

Get form values into hook_node_insert / hook_node_update

I need to get in hook_node_insert and hook_node_update the value of a field I manually added to a form. function hook_form_FORMID_alter(&$form, FormStateInterface $formState, $form_id) { $...
0
votes
0answers
4 views

Limit theme_webform_element() to One Form for Placing Description Above Field?

I have a very long webform, more than 200 fields, where the description needs to go above the input/textarea and below the label, instead of below the input/textarea. I am using webform 7.4.x and I ...
3
votes
1answer
40 views

How to add autocomplete to a textarea on a form?

I would like to add autocomplete functionality to a textarea form element in Drupal 8. I have a fully functioning custom textfield which has autocomplete working on the same form. I have confirmed ...
0
votes
1answer
11 views

Using JCF with dynamic forms

I want to use Javascript Custom Forms (JCF) to get more attractive and consistent looking forms on my Drupal 7 site. I've got it working to a degree, however when the form changes with AJAX, the new ...
0
votes
0answers
11 views

Ajax error on form submit

When I submit the form on the website(example: http://www.megatechnika.ru/node/109/ ) the form isn't sent to the server. And there is an alert showing with /system/ajax/ 500 error and a following text:...
0
votes
0answers
32 views

Render the comment form after an error message

I have a template (node--een-voorwerp-schatten.html.twig) that renders nodes. One of the variables renders a comment field ({{ content.field_doe_een_schatting }}), where visitors can input a value. ...
2
votes
1answer
13 views

Override one line in core tabelselect jQuery behavior so custom checkboxes aren't affected

I have created a custom table using a Form API tableselect element, and within my table, I have embedded a checkbox form element that is checked based on an entity field (see here for details). The ...
1
vote
0answers
20 views

How to set fields (widgets) to readonly in hook_form_alter

Some fields of my nodes get regularly updated by an external datasource and therefore should not be edited by editors in Drupal. But for UX reasons I still need those fields visible on the edit form. ...
0
votes
1answer
17 views

Modify/Alter Password Policy Constraints Text

I'm looking for the easiest possible way to modify or alter the password policy constraints error text. The following is the default the users see. The password does not include enough variation to ...
0
votes
0answers
11 views

Custom Ajax forms with managed_file form element

We have a form with three fields - where depending on the value of the first select field, we will show the other two form elements - one select field (the options depends on the value of the first ...
0
votes
1answer
25 views

file name constraint in form

I've got a basic field constraint figured out (per question here: Validation constraints on form fields ignored ) Next, I want to constrain the main image field to limit the file name. For example, ...
0
votes
1answer
17 views

Display entity as options_select multi-select

Below is my code for the view. I have tried multiple = true, multiple_values=true, multiple = multiple. None have worked. ->setDisplayOptions('form', [ 'type' => 'options_select', '...
0
votes
1answer
61 views

Validation constraints on form fields ignored

Trying to figure out custom validation with constraints, but no luck yet. Right now, my form posts content and gives no errors when form is filled out incorrectly. (Please avoid suggesting ...
0
votes
1answer
15 views

Custom form page URL changing on validation error [closed]

I have a registration form opening on this url www.<mywebsite>/user/register?name=john When I fill up my form and submit it then on validation error it goes to the www.<mywebsite>/user/...
-3
votes
0answers
18 views

I created a custom module to create forms, the forms created are not going to database [closed]

any help for "I created a custom module to create forms, the forms created are not going to database in drupal8". please.
1
vote
2answers
22 views

Unable to set default value for checkbox form element inside tableselect

I've created a custom table using a tableselect element, and within each row, I have a checkbox form element that should populate the checkbox from a checkbox field in the node. I've tried every ...
1
vote
1answer
22 views

How to make a select form element with textfields for the array id and key?

In a custom module which I'm working on, I have a select list which currently has a hard-coded array of key=>value which could change and I would like to expose these options to the user. I would ...
1
vote
1answer
29 views

How to use ConfirmFormBase to confirm the action of another form?

I have a form that allows users to upload a CSV file. Upon submit, I would like to show a confirmation form ("Are you sure you want to import this file?"). However, the Drupal 8 examples for ...
-4
votes
1answer
37 views

How to design multiple versions of a form? [closed]

I am working on the forms in Drupal. I have to design 50 forms. All the forms have 90% of fields in common do I need to redesign form each and every time?
0
votes
0answers
22 views

How to know the type of store?

Drupal 8 and Drupal Commerce 2.10 I have several types of store on my site and I want to modify the button Add to cart of all the products associated with the store type online (online is the machine ...
0
votes
1answer
20 views

Custom Entity: define a view in entity reference field

I defined a custom entity and for a entity reference field I want to set the view reference widget and a view/ display to be used instead of an autocomplete. I tried many different settings - nothing ...
0
votes
0answers
37 views

Allow Custom Form Field '#default_value' to be 0 in Elvis Operator

Dupal 8.x I have a custom form field where the value could be zero for radio elements: $yes_no_options = [ '1' => t('Yes'), '0' => t('No'), ]; $form['config_name'] = [ '#options' => $...
0
votes
0answers
18 views

How to get a single node field into custom form

I have a custom form in which referenced field needs to be displayed. Here is the structure: Content-Type: Project Reference Field in Project Content-Type: POD Details(Fields- MemberName: User ...
0
votes
0answers
11 views

How to use element validation and form validation on the same form?

I have a custom form I am validating with a custom validation function like this: … $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit'), '#validate' => array('...
0
votes
1answer
23 views

Pass list from Jquery to form

I have an AJAX form that I've created into a block exposed on my current page. I will have an interface that will allow the users to select an indefinite amount of content to be used within the submit ...
1
vote
0answers
26 views

Form alter on date parts

I'm trying to add attributes to a date form field. The field renders as day month year in separate inputs. I cannot work out how to add the form alter to these specific inputs. I've tried ...
0
votes
1answer
35 views

How to validate allowed file types in custom module

I want to validate a field with accepted file type as PDF, XLS, JPEG, JPG, GIF, ZIP, RAR and PNG. I'm getting file types as PDF, XLS etc. here is part of my code. if ($fi_name!='') { if ($...
0
votes
1answer
22 views

States with a variable

I have to do a form and in this form I have a select to choose a value, from this value I load a node and from this node I get a boolean. With this boolean I have to show or not another form field, ...
0
votes
1answer
25 views

Changing form field requirement via ajax

I have a selectbox field, that should change the disabled and required states of another field based on the value selected in the selectbox field. The change must be done via ajax. In my modules ...
0
votes
0answers
13 views

Using Inline Entity Form with Form API [duplicate]

I'm working on a Drupal 7 project. I have created a custom module with 2 custom entities (profile hasMany users). The db tables are created through the Schema API. I have created a form using the ...
0
votes
0answers
10 views

How 'checkboxes' form element supposedly can have #default_value if there is nothing to make this work? Or is there?

So, documentation indicates that 'checkboxes' element is making use of '#default_values' property. There are multiple threads indicating that it's possible, like: Checkboxes: how do I set the default ...
0
votes
0answers
24 views

How to add image field in a custom module form?

In our custom module, mymodule we have a form MyModuleForm where we want to allow for an image to be uploaded or chosen from already uploaded images. Below is the MyModuleForm.php file, but cannot ...
0
votes
0answers
14 views

Fieldset title with no <a> tag when internationalization installed

Working on a multilanguage Drupal 7 site. When forms are rendered in an alternative language, the fieldset titles loose the <a> tags hence collapse functionality vanishes. Form API element ...
0
votes
1answer
24 views

Posting to a form via external URL

I am writing an application (non-Drupal) that is POSTing to a 3rd party public form written in Drupal. The problem I am running into is that the 3rd party form never processes the request, it only ...
0
votes
1answer
33 views

Programmatically set value of Boolean radio button field in form

I am using a custom field in the profile2 module for when a user registers. The field is a Boolean field using the radio button widget. I want to programmatically set the value for the field using ...
0
votes
1answer
15 views

Themeing custom form as table and getting updated field values on submit

In my attempt to create a table that shows all of the locales for a node and contains two editable fields, I've come up with the following functions: function language_dashboard_overview_form($form, &...
1
vote
0answers
10 views

How can I group checkboxes in my custom ER widget?

I have created custom entity reference widget. Basically I need checkboxes inside my form element. But they have to be grouped by "Row" field presented on referenced entity type. I'm not sure is it ...
0
votes
1answer
21 views

lost password “user-pass” form no more redering

We didn't touch our templates and the "lost password" form is no more rendering. here is my template code working fine with $login_form. <div id="login-container"> <div class="login-hint"...
0
votes
1answer
36 views

How to define template suggestions for node add and edit form by content type?

I have a content type Project and it has a more than 100 fields in the node form. The form fields are grouped in different section and category. I tried to use a field_group module to group and ...
0
votes
0answers
20 views

AJAX Form Not Submitting Until After Cache Clear

I'm working on a module that needs to add a form to a page that submits via AJAX. My form consists of a text field and a submit button with callback: $form['my_text'] = [ '#type' => '...
1
vote
1answer
17 views

Change the display name of a default field in Contact Form

In Drupal 8, I LOVE that there are default fields in Contact Forms for Name, Email, Subject, and Message...but in several of our forms those labels don't make sense. For example, one form's primary ...
0
votes
0answers
20 views

Form submit doesn't work first time

When orgno changes brreg_field_ajax_callback is called, company field is filled by js (And it's ok, work fine); but when i click on submit (there are other fields, without #ajax) the page is refreshed ...
0
votes
1answer
19 views

Date popup field won't display in tableselect element

I am attempting to embed a couple of date fields within a tableselect element, and after trying to use both textfield and date_popup field types, I can't get either to work. Here's my form function ...
0
votes
0answers
21 views

Submit handler not called when loaded Ajax

Form submit handler is not called when form is loaded via ajax in a page. function hook_menu(){ $items['fetch_info'] = array( 'page callback' => 'fetch_info_ajax', 'access callback' => ...
0
votes
0answers
20 views

Entity Form Builder bypasses Access Handler on submit?

I have a ECK Entity, it is allowed to be edited only by admins. Under a custom route /test I load the form with \Drupal::service('entity.form_builder')->getForm($entity, 'default'); Now as an ...
1
vote
2answers
72 views

How to sort language select list on current language context

I have a form with a language field with the language select list widget. The options of this field contains an array with a pattern like ['langcode' => t('language')] Now I want to sort these ...
2
votes
0answers
30 views

How to add a modifier to a form id? [duplicate]

If I form alter a form, I see the form_id as MY_FORM_ID; I see this in the $form_id parameter to hook_form_alter as well as in the $form_state->build_info['form_id']. In the rendered output of the ...
0
votes
1answer
29 views

Form incorrectly displays differently depending on logged in user's role

All logged in users can add a forum node. The current topic is determined by a field in another node (nid=77) and set to the default value for the node being created by this form. While this all ...