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
13 views

#ajax not working on views exposed form [on hold]

I attached ajax to views exposed filters in form_alter but not working. For other forms, ajax is working. But adding #ajax to views exposed form fails. Any thing special with views exposed form block? ...
1
vote
1answer
11 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
21 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
13 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
22 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
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 ...
0
votes
0answers
22 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 ...
-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
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
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,...
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 ...
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
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
24 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
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 ...
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
25 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
24 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
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 ...
1
vote
1answer
22 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
15 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 ...
-1
votes
0answers
16 views

How to use Ajax to dynamically render a new paragraph with DB data?

I'm kinda starting with Drupal 8 and I need some help. I have a dropdown in a custom block which options are taken from a DB. Now, I would like to create an Ajax callback that could take the value ...
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
14 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(&$...
0
votes
0answers
7 views

AJAX rebuild single form element

I'm trying to get an AJAX-enabled form working. Users should be able to tab between fields using the keyboard, and when a user tabs to the next element, I want the name span after the previous-focused ...
0
votes
0answers
35 views

Ajax on Gmap marker placing

I've got a geofield and an address field on my content type, there is a geocoder module which can hide geofield and set it's value based on the addressfield value when the entity is saved. what I ...
-1
votes
1answer
35 views

Wizard or Form to create 5 nodes of 3 content types [closed]

I'm building a genealogy site. One of the most important use cases is to create an individual. I want to use a single form to capture information that will be used to create up to five nodes after ...
0
votes
0answers
16 views

get value of select dropdown

I'm trying to take values from dynamic select boxes I retrieve them from the database here is the code foreach ($courses as $course) { $query = db_select('Lab'); ...
1
vote
0answers
9 views

Form submits before File Upload completes

I have a form. It works... but the user must wait for the large file to upload first or they won't be processed by the form. The upload form will change from the Upload button to the name of the file ...
0
votes
0answers
21 views

add custom class for each field of a form

I am trying to create a custom class for the fields based on the title display dropdown for each field, and I have it most of the way working. I was wondering if anyone might have any ideas on this. ...
-2
votes
0answers
35 views

Data entry interface?

I'm trying to create simple web-app. In a from-scratch approach I will first create my db-schema. From what I understood the equivalent of db TABLE in Drupal is Content-type. So I created one, added ...
1
vote
1answer
20 views

How to render image uploaded from a configuration form

I'm working on a custom module, that contains a block and I'm currently having an issue to render an image that is being uploaded through a form at the configuration of the block. I'm getting this ...
0
votes
0answers
11 views

Drupal form element AJAX calls only if it has changed

I have a form with AJAX-enabled textfields. I currently have it working such that when a textfield loses focus, its AJAX callback is called. $form['entry'][] = array( '#type' => 'textfield', '#...
0
votes
1answer
32 views

How do I know what setSetting is suppose to be?

I am creating a custom content entity and in the BaseFieldDefinitions, I am trying to create a field for assigning a user as the designated assigner and will follow up with a assignee. So far, the ...
0
votes
1answer
21 views

How can I use a content type field on the body of the e-mail message template on the Webform module?

For usability matters, I would like to let the editor create his own confirmation message on my Event content type. So I create a field for that. I also have another field to select which webform is ...
0
votes
0answers
20 views

Validation after all other validations were successful

I have a form with several form fields and two validation handlers. function my_module_my_form_validate_integer($element, &$form_state) { // validation stuff } function ...
0
votes
1answer
14 views

How to use a token in the reference fields

1-I have a node with the name of the project. 2-this node has a project_name field that generates by these Tokens 3- I have a reference field that it load an entity type in the project create the ...
0
votes
1answer
116 views

Programmatically auto-submit a Webform after visiting its URL

I am wondering whether it's possible to programmatically auto-submit a Webform after visiting its URL and to save the user from a 'submit' button click. The below webform can be accessed via /form/my-...
0
votes
0answers
41 views

How to serialize a form's render array to JSON

I want to build a REST resource to return Forms as JSON with all labels, help text, default values, etc... When I use REST's built-in resource /entity/entity_form_display/node.article.default it does ...
1
vote
0answers
31 views

How to prepopulate a field from parent form to Inline Entity Form

I have 2 content types - Employee and Project. Both forms have Inline Entity Forms with references to content of each other when user creates an Employee node, he can add projects he took part in, ...
0
votes
0answers
13 views

Validating Tableselect: Checkbox

I have a form in which i have created a table like the following $form['tableselect_phone'] = array( '#type' => 'tableselect', '#header' => $header, '#options' => $options, '#...
1
vote
2answers
30 views

Prevent form regeneration when a callback function is called through ajax

Here is the code for the custom form with a field(field_B) that calls an function through ajax. The issue is that I want the function (MY_MODULE_XYZ_function()) to be executed only once, when the ...
0
votes
1answer
37 views

Remove an item from $form_state in an ajax callback

I'm using this form api example: AjaxAddMore. I want to add a "remove button" for each indiviaul element, in order to remove an item but not the latest. Thouse are my changes: ... $form['...
0
votes
0answers
23 views

Programmatically create master/detail forms

I want to create a master/detail form in my custom module using form api and ajax. I have three content types: CT1, CT2 and CT3. CT1 is the master, and CT2 and CT3 are details of CT1 (they have a ...
0
votes
1answer
20 views

Form #after_build is not working for PHP 7x

I'm using #after_build in one of my custom module form like follows $form['profile_image'] = array ( '#type' => 'managed_file', '#after_build' => array("change_pic"), ); and the ...
0
votes
0answers
24 views

Use autocomplete with an infinite cardinality

I am trying to attach a list of users to a new entity I am creating. I want to enable autocomplete on those fields but I can't get it to work. For the moment, my field looks like this : array( ...
0
votes
0answers
14 views

Vertical Tabs: Wrapper problem

I have a form with several fieldsets and i am thinking about adding a vertical tabs form field to turn the current fieldset to vertical tabs but i use a lot of AJAX in the fieldsets. The AJAX elements ...
0
votes
0answers
16 views

Unexplained (buggy?) behavior of drupal_process_states with checkboxes in Drupal 7

I have 3 checkboxes named A, B, C. My desired behavior is as follows: if, and only if, both A and B are unchecked, then C becomes checked. Inversely, if either A or B are checked, C becomes unchecked. ...