Skip to main content

Questions tagged [forms]

Use it for questions about the Form API. Don't use it for entity or entity field forms.

Filter by
Sorted by
Tagged with
-4 votes
0 answers
18 views

Pardot form iFrame is taking lots of time to load [closed]

The Salesforce Pardot lead form iframe loads fine separately, but when it's called on the Drupal CMS website, the webpage loads properly while the iframe takes about 15-20 seconds to load.
user114932's user avatar
0 votes
0 answers
16 views

Clear smart_date time input values after validation error

I have a smart_date field. During creation of a content with the smart_date field, when an error occurs on the time/date such as incorrect format, etc.. I want the values to be cleared. Here is what I ...
Gabriel Fernandez's user avatar
0 votes
0 answers
17 views

Hierarchical select modules are showing excessive widgets during entity editing

For a few months now I noticed some difficulty editing entities using either 'simple hierarchical select' formatter or the 'client side hierarchical select' formatter. The widget splits up offering ...
Chike's user avatar
  • 25
0 votes
1 answer
57 views

Submitting an existing block or form in a modal doesn't work

I am trying to open either the simplenews subsription block or the corresponding form in a modal. I tried with both the form using the formBuilder service or the exising plugin-block and in both cases ...
Mike's user avatar
  • 1
0 votes
0 answers
10 views

Delete image from form after invalidated

I made a custom hook_alter_form to invalidate and delete a image if invalid. php code in the .module file <?php /** * Implements hook_form_alter() to add custom validation for image ratio. */ ...
Simon Van den Bossche's user avatar
0 votes
0 answers
57 views

How add a cache context in a form_alter?

I'm on Drupal 10.2.x. I'm writing a form_alter for a node add/edit form, where I am putting some extra markup data depending on terms of a vocabulary licenses. function my_module_form_alter(&$form,...
Giuseppe's user avatar
  • 971
0 votes
0 answers
44 views

File upload becomes empty after form submit for anonymous users

I've build a form in Drupal 9 with Form API. When logged in as admin, all is working fine. Selecting a file as anonymous works, and the validations are checked. But when I submit the form, the ...
user3086053's user avatar
1 vote
1 answer
97 views

How override theme for a node add\edit form?

I'm on D10.2.x. My site uses Gin as back-end theme but also as fallback front-end, being decoupled and having to "front-end page" actually shown via Drupal. I'd want to override the default ...
Giuseppe's user avatar
  • 971
1 vote
0 answers
58 views

How to make a GET request to return Entity Registration form fields?

I am using Drupal as a decoupled CMS with Entity Registration module, and would like to get the Registration Type form fields to display on my SPA. I have enabled the REST resource: /entity/...
Brownrice's user avatar
  • 111
0 votes
0 answers
9 views

How can I manipulate an autocomplete text field exposed form filter to be a select list? [duplicate]

I have been trying to just use a form alter hook with code like this if ($form['#id'] == 'views-exposed-form-my-form') { $nids = \Drupal::entityQuery('node') ->accessCheck(FALSE) -&...
Steve's user avatar
  • 361
0 votes
0 answers
44 views

What is the valid value for Webform element type in form-element.html.twig?

I'm currently attempting to rewrite the form-element.html.twig to incorporate custom CSS based on the label display and field type for Webform element output. While I've successfully identified ...
CocoSkin's user avatar
  • 891
0 votes
0 answers
27 views

Inline Entity Form - how to set form field value in custom validate function

I have been struggling with this problem for few hours and I am unable to set form field values in a custom validate handler for an Inline Entity Form. Inside _inline_entity_form_entity_form_alter ...
a_negi's user avatar
  • 1
0 votes
0 answers
24 views

Change webform error status message

I'm working on making my webform on my site (D10) completely accessible. When I'm submitting my form empty I get a status message because I have two required fields. The message is: 2 errors have been ...
Joost's user avatar
  • 1,348
0 votes
0 answers
19 views

How to add dynamic dependency between two entity reference fields in content creation form?

I want to create a dependency between two Entity Reference (ER) fields, one towards content and the other towards vocabulary terms. My first content type A has an ER field (A1) to a vocabulary (V1) ...
Toki's user avatar
  • 424
0 votes
1 answer
12 views

Create input name from array like #parent

I'm just wondering if there is a Drupal way / helper function to build input[name] string from array. So I have an array '#parents' = ["info","variation-555-1","example",&...
Dylan's user avatar
  • 428
1 vote
1 answer
40 views

How to get entity object in buildform formbase?

I've the following in my routing.yml project.product_elasticsearch: path: '/product/{commerce_product}/elasticsearch' defaults: _form: '\Drupal\mymodule\Form\ProductElasticsearchForm' ...
Sivaji's user avatar
  • 2,478
0 votes
0 answers
20 views

How do I render TH for individual rows of a table?

In the example below, how do I make a1 and a2 into <th> instead of <td>? I want an html table like: <table data-drupal-selector="edit-test" id="edit-test" class=&...
Kevin Finkenbinder's user avatar
0 votes
0 answers
47 views

'#empty_option' not working for nested select list

I have a form with several select lists, the select lists that are not nested show the "#empty_option" as expected, but the ones in a nested container do not work. Expected output: the "...
Kevin Finkenbinder's user avatar
0 votes
0 answers
44 views

Why isn't Messenger working as expected in my submitForm?

I have this custom form (which is a tableselect): In the submitForm, there are two possible cases: The user has already made a reservation and a warning message is displayed: The user makes his ...
gbmapo's user avatar
  • 1,086
1 vote
1 answer
71 views

How to inject extra data into entity reference checkbox form widget

I've a taxonomy tree used in an entity reference field, which requires some custom rules (e.g. if any option of subtree A is chcked, then any option of subtree B is disallowed or if any option of ...
Hudri's user avatar
  • 5,539
0 votes
1 answer
84 views

Programmatically updating a Webform submission with a file element doesn't remove the attached files

I am using Drupal 9.3 and Webform 6.1.7. I have a Webform that contains a file element and am building a custom form to update the submission data. I have found that when I submit my custom form I can ...
inertiahz's user avatar
  • 303
0 votes
0 answers
34 views

Can i add my custom user field to a user mail template? [duplicate]

I added a custom user field (/admin/config/people/accounts/fields) with machine name field_about_user to my D9.5 site (yes i know, it needs updating...). Now i tried to add that field to the Mail ...
sirtet's user avatar
  • 63
2 votes
0 answers
23 views

jQuery timepicker on custom FAPI form element

How can i add jQuery timepicker to custom form element. There is some description on API docs: #date_time_callbacks: An array of optional callbacks for the time >element. Can be used to add a ...
Ev Tr's user avatar
  • 21
0 votes
1 answer
47 views

What is the calling method of validateForm callback of a FormInterface subclass

i just want to know where in the drupal code the validateForm method is called from the FormBuilder. In the doValidateForm of FormValidator class i don't see the callback being called ! Can you give ...
Frédéric Hébert's user avatar
0 votes
0 answers
52 views

How to add a description(alternate text) for a custom file field created

I have to a description text field a file field created in form alter $form['test_file'] = [ '#type' => 'managed_file', '#title' => t('File Upload'), '#...
Aziya's user avatar
  • 11
0 votes
1 answer
45 views

how to get the default value for a multivalue field

I'm using the Mulitvalue Field module (https://www.drupal.org/project/multivaluefield) and I created a form like this and it successfully sets the various emails into the configuration file, but when ...
Diana's user avatar
  • 3,294
0 votes
1 answer
74 views

How do I link to a custom form mode in a (node) tab?

My issue is my form is too big and too slow, with nested paragraphs, media entities and so on, the biggest issue is the metatag-module with its 100s of fields. So I thought I just add a new form ...
Stephan Steege's user avatar
0 votes
1 answer
46 views

CKEditor returns a value as array

In my Form I have this entry that presents a CKEditor instance $form['notes'] = array( '#input_format' => '1', '#rows' => '5', '#type' => 'text_format', '#base_type' => '...
Cy Jobes's user avatar
0 votes
1 answer
132 views

How to make #description appear on a field widget?

I have a custom field widget that extends WidgetBase. My formElement method looks like this: public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, ...
JAyenGreen's user avatar
0 votes
1 answer
174 views

How to add a reset button to forms?

How do I add a reset button to a form? I have a form with a CKEditor and other fields, plus hidden fields. How do I reset the form so all fields are empty?
Cy Jobes's user avatar
0 votes
0 answers
88 views

What's the standard way of passing a return URL to a form?

The scenario is simple. I've constructed a Link object whose URL points to a form. I need a way to pass a URL to that form so that proper redirection can happen after the form is submitted. Passing a ...
ilechcod's user avatar
  • 123
-1 votes
2 answers
165 views

How can I compare date time values in a content form?

I want to use getString() instead of [0]['value']. How do I do that, if it possible? Is there any other way? This is the array I get when I run this code. dump($form_state->getValue('...
-1 votes
1 answer
51 views

How to use the Tableselect element for an order-able list of items?

It's been a minute since I have used tableselect. I want to present a user with a list of sortable options that have checkboxes to indicate they are on or off. See this screenshot: While the table ...
Kevin's user avatar
  • 27.9k
1 vote
0 answers
122 views

How can I create a custom "Add to cart" form?

I'm developing a basic Commerce shop with Drupal 10. The product type is clothing, which has a single product variation (product_size) and three different product attributes for that variation. The ...
SlowCheetah's user avatar
0 votes
1 answer
244 views

Make a custom action with form

I am trying to make a custom user action where the selected users will have a node created manually, however I need to create a form to save the data that this node will have, such as: title, start ...
Juan Carlos Osorio's user avatar
0 votes
1 answer
95 views

missing form tag while embedding and stylizing form elements

I am wanting to embedd a form into a twig template, but place the elements where and how I want them. The idea is to have better control over the layout without having to use the $form array to ...
Cy Jobes's user avatar
0 votes
1 answer
35 views

Prepopulating a drop-down select box that references another entity

I have a node create form for content type "space" so that the URL looks like https://.../node/add/space. In this page, there is a form with a drop-down select that corresponds to an entity ...
BMM's user avatar
  • 103
0 votes
0 answers
33 views

Filtering dropdown selectable values depending on the selected value on another dropdown - in a content creation page

I have 3 content types: "Floors", "Spaces" and "Resources". One floor can have multiple spaces, and one space can have multiple resources. "Floor" has only a ...
BMM's user avatar
  • 103
0 votes
1 answer
505 views

How to use 'required' and 'optional' states with form api when using a select field?

I'm trying to create a form in Drupal 10 that will show an field that is both visible and required depending on the selection of a radio input that comes before it. The visible state seems to work ...
blu's user avatar
  • 448
0 votes
1 answer
156 views

Why is my message not showing for anonymous user?

In a custom form, I have this Ajax submit: public function ajaxSubmit(array &$form, FormStateInterface $form_state) { $response = new AjaxResponse(); if ($form_state->hasAnyErrors()) ...
gbmapo's user avatar
  • 1,086
1 vote
0 answers
99 views

How can I have both file download and redirection in for submit?

I have this form submit: public function submitForm(array &$form, FormStateInterface $form_state){ // File download $sFileName = 'JdP-Adhesion.pdf'; $sFileNameWithPath = 'sites/default/...
gbmapo's user avatar
  • 1,086
1 vote
0 answers
112 views

Alter the address fields of the address module like adding a placeholder

I made a form with the FormAPI to update the address fields of the address module (with Drupal commerce) and it works well. But I saw a topic where you could generate the form with an address type ...
Sébastien Gicquel's user avatar
-1 votes
2 answers
178 views

How to add a link to table row?

There is a field 'field_upload_artwork' that contains files. I am using them to build links to files and want to insert links after Apparel Printing in the last step of the form. Now the markup in ...
nathan111777's user avatar
0 votes
1 answer
73 views

Why doesn't my completion message show?

I have this form to handle a custom content entity: created by this code: public function buildForm(array $form, FormStateInterface $form_state, $contractId = NULL) { Some code to inialize ...
gbmapo's user avatar
  • 1,086
1 vote
1 answer
75 views

How to add extra validate hook to the order information form?

I am trying to collect additional information on checkout to add to the order. I have added new fields to the order entity and then used hook_form_commerce_checkout_flow_multistep_default_alter to add ...
liquidcms's user avatar
  • 1,278
0 votes
0 answers
86 views

TriggeringElement not working properly for my ajax form

<?php namespace Drupal\demo\Form; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Component\Serialization\Json; use Drupal\node\Entity\Node; use \Drupal\...
Z CHAMP's user avatar
  • 42
0 votes
1 answer
146 views

Why does Ajax prevents managed_file to be displayed?

I have this form created by this code: public function buildForm(array $form, FormStateInterface $form_state, $contractId = NULL) { some initialisation code... $database = \Drupal::database(...
gbmapo's user avatar
  • 1,086
0 votes
0 answers
77 views

massageFormValues not being run on custom form

I've built a widget for my custom field and this works OK when I create / update a "normal" node edit via the normal D10 content interface & forms. I've added this widget to a custom ...
Alex Monaghan's user avatar
0 votes
1 answer
133 views

How to update migration field mapping using custom module/form?

I was learning about Drupal migration recently and found out that we can use Migrate Plus module to import migrations as configurations. Hence I started wondering if a migration is imported as a ...
SGupta's user avatar
  • 1
0 votes
2 answers
143 views

How to do Do a redirect in buildForm()?

I send a link to a URL by email. This page is created with a controller which contains a form (FormAPI). I pass a token as a parameter to secure access to this form. So I check if this token exists ...
Sébastien Gicquel's user avatar

1
2 3 4 5
137