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
0answers
3 views

Cannot get form values set in a ajax callback

In the hook_form_alter, I add 3 textfield form elements and 1 button with ajax callback: function zwznertags_form_alter(&$form, &$form_state, $form_id) { if($form_id == 'book_node_form') { ...
0
votes
0answers
24 views

Delete records from database pressing a button in twig

Drupal version: 8.7.x I created a module that retrieves meals based on the given ingredients. I display the ingredients with a delete button and the meals underneath them. However I don't know where ...
0
votes
0answers
16 views

How can i do Webform field custom validation

I want to do a custom validation for a field in some of my webforms. I came across this code: https://www.drupal.org/docs/8/modules/webform/webform-cookbook/how-to-add-custom-validation-to-a-webform-...
1
vote
0answers
81 views

Why isn't my custom Form API #states applied in my webform yaml editor working?

I have the need to set visibility state of a checkbox option in one question (Table checkbox select) based on the value of another checkbox in the same table. I also have other scenarios where I would ...
0
votes
0answers
19 views

How to set an array of hidden form fields using $form_state->setValues

I want to set hidden fields (permission by field) of a form in Drupal 8. The fields in the form have the names field_pbf_municipality[0]['target_id'] field_pbf_municipality[0]['grant_public'] ...
0
votes
1answer
32 views

How do i use onHourShow callback in a date_popup control with the Form API [closed]

On my form I have a date_popup control: $form['order-group']['delivery'] = array( '#title' => t('I Need The Equipment Ready By'), '#type' => 'date_popup', ...
0
votes
0answers
21 views

Modifying Page Title To Be Separate From Browser Title [duplicate]

I have a module that contains multiple forms, each form in its own file. I need to modify the page title such that it is different from the browser title for several of these pages. The name of the ...
-1
votes
0answers
18 views

Select options shown in wrong order [closed]

So I have a form element like this: $form['country'] = array( '#type' => 'select', '#options' => mymodule_country_select_list(), '#title' => t('Country'), '#required' => TRUE, '#...
0
votes
0answers
19 views

Drupal 8 : Multiple Submit Handler

I am using Drupal 8.6 for creating custom module in Admin. I have a custom form where i have to use multiple submit button for form submission. I am not able to submit the my form to specific function....
0
votes
1answer
16 views

Form with manged_file filed is not submitted?

I have a form in my drupal module. in my form, I have used manged_file field. form name is "difference_form" and I have created two functions. one is "function diffence_form" for form definitions. ...
-1
votes
0answers
12 views

Can't able to add Drupal 8 Commerce PayPal Checkout details [closed]

I'm trying to add paypal module in drupal 8 commerce functionality. And i downloaded paypal 8.x-1.0-beta4 version then installed and enabled. After that i trying to add paypal checkout payment gateway ...
0
votes
0answers
26 views

Initial values in forms elements

When I create a form (using form api) I need, sometimes, to assign a default value to form elements, or to create a list for select elements, under certains conditions. In this cases, I need to do ...
0
votes
1answer
25 views

How to add unique class to each checkbox elements

I am displaying checkboxes using form API in Drupal 8. For functional and theming purpose I need to add unique custom class to each checkbox element. Is there any way to add classes to each checkbox ...
0
votes
1answer
35 views

How to modify a form to have some field surrounded by 'Details'?

I created a custom content entity with Drupal Console. Three of its fields are defined this way: // ---------------------------------------------------------------------------- $weight++; $...
0
votes
1answer
24 views

How can i add ajax callback to checkbox in drupal form?

I am using taxonomy manager module I want to add ajax callback to checkbox tree view for checkbox is checked condition but it is not working can some one please suggest me. I have modified the code ...
0
votes
1answer
19 views

D8 | Custom Form managed_file field limit number of upload files

I have a custom form in D8. Form has managed_file field. I am facing challenge regarding the limit of number of files upload to this field. I have to make this managed_file field to upload only 3 ...
0
votes
2answers
23 views

How do I get the form submitted data in a custom module? [duplicate]

I have create a webform in Drupal 7. I want to access the submitted data in a custom module. I used my_module_form_submit($form, &$form_state) but no data has been found. Please Help.
0
votes
2answers
26 views

just want to change checkbox value while submit

I am using drupal 7: $form['title']['#tree'] = TRUE; $form['title']['node_first'] = array( '#type' => 'checkboxes', '#options' => array( 'value' => $value->title, ), )...
0
votes
1answer
51 views

print data to twig file from custom form submit via controller

I have created a custom form, and I'm passing data to twig file from submitForm function as follows public function submitForm(array &$form, FormStateInterface $form_state) { $form_state->...
-1
votes
0answers
15 views

Confirmation popup Box according to a condition on submit button

I am using Drupal 7. In my list I have 2000 subscribers. Now I want a confirmation box before executing the form. The only issue is If I have more than 20 users I want the confirmation form to ask ...
1
vote
0answers
17 views

scrolling after posting drupal ajax form

I am working on an existing site which has a Drupal 8 multi-step form which uses Ajax Upon submitting the form (on the final step) the page scrolls to the top where a thank you message has been ...
0
votes
0answers
32 views

Ajax implementation in exposed forms

We use to add property '#ajax' to a form element in our form array, to trigger an Ajax response and it works fine except in case of views exposed forms. This doesn't work in case of views exposed ...
1
vote
0answers
27 views

Have Value Selected but Label Showing in Views Display Plugin

I am working on a custom Display plugin for Views. In my buildOptionsForm() method, I have the following: $form['inherit_yaxis'] = [ '#title' => $this->t('The title'), '#type' => 'radios'...
0
votes
0answers
21 views

How does the register form in the user module load ImageWidget?

I want to use the user picture widget on the user register form to capture an image. So for my custom entity form I'm using the managed_file as such modules/custom_module/src/CustomEntityForm.php ...
0
votes
0answers
43 views

dependency injection by using $this when not in object context

if i´m using the codesniffer function i´m getting two warnings about: 155 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead If i´m changing the line from: $...
1
vote
1answer
46 views

Possible to theme the form's elements with own twig?

I was thinking to get twig outputs so I could use these twig variables on a form.html.twig such as below: <div class="row"> <div class="col-md-6"> {{ form.name }} ...
0
votes
2answers
28 views

Can't find the cause of this error

I am working through a Drupal 8 module building exercise from YouTube and I am not able to figure out what is causing an error. The relevant page loads and displays the form but I get the following ...
0
votes
0answers
16 views

How to set a node as context?

I have a little web app where I have two node types: Customers (/customer1, /customer2) Notes about customers The notes about the customers have an entity reference to the customer. I like to create ...
0
votes
2answers
26 views

Ajax error render

I receive this error message when I try my custom form in Drupal 8. User error: "0" is an invalid render array key in Drupal\Core\Render\Element::children() This is the code I am using namespace ...
0
votes
0answers
14 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
19 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 ...
0
votes
1answer
29 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
2answers
37 views

Views callback work only once with advanced form block

this code work but the views is callback only once (reload only once), any idea to reload more than one time ? see in detail on drupal.org function modulename_form_alter (&$form, &$...
-4
votes
1answer
34 views

Calling Drupal Form from non-Drupal 3rd Party Website [closed]

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
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....
0
votes
2answers
33 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,...
1
vote
1answer
21 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 ...
1
vote
2answers
27 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
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
0answers
26 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 ...
1
vote
2answers
71 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 ...
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()->...
0
votes
2answers
30 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 ...
2
votes
1answer
31 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?
0
votes
1answer
44 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 ...
1
vote
1answer
26 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 ...
1
vote
2answers
25 views

Populate a field in form alter with user name and one with user ID

can someone tell me why this works function justatest_form_alter(&$form, $form_state, $form_id) { global $user; if ( $form_id == 'node_test_form'){ $form['field_owner']['widget'][0]['...
0
votes
0answers
17 views

form field description tags stay after ajax rebuild

When i rebuild my page via ajax e.g. with a button that dynamically adds additional form fields, the description tags (tooltips) of the Bootstrap theme that were shown to the user in the moment of the ...
0
votes
0answers
21 views

How do I get the default comment form in the content type template?

I have created the comment field in the content type. How can I render the comment form using a specific content type template in Drupal 8?
0
votes
0answers
17 views

Add a custom button to a views exposed filter form

I'd like to add a custom button near the "apply" button on a view exposed filter form. To do that I have created my own module and added a hook: function mymodule_form_views_exposed_form_alter(&$...