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
-1
votes
1answer
26 views

Add a date pop in a field in custom module

I want to add a date pop in a custom field in custom form in custom module This is the library file: custom_lib: css: theme: css/datebasesorting.css: {} css/datatables.min.css: {} ...
0
votes
1answer
21 views

Templating the user edit page

i'm using the theme startupgrowth lite and i want to theme my user edit page , only when the user is a 'testeur' and he's editing the 'candidate user profile'. i know that when i want to modify the ...
0
votes
0answers
11 views

Display Default and filter data of a form on a same page including form

I want to show the date without filter a form that is default data and if user apply for filter and filter should be shown rather to default data including form at the top Basically I have created a ...
1
vote
0answers
24 views

How to reload flagging form via ajax?

My task is to ajaxify complex flag form (with additional fields). I need this because the default ajax flag does not dupport fiedls. I need to have the flagging form for create flag and then update it ...
-1
votes
2answers
57 views

How do I sanitize the uploaded files name for sending safely as email attachments?

I have create a form that upload a file. This file is send as email attachment .. $form['cv'] = [ '#type' => 'managed_file', '#title' => 'Votre CV', '#...
0
votes
1answer
43 views

After rendering entity form how can be modified?

I rendering a custom entity form display with the following code: $form = $this->entityFormBuilder->getForm($entity, 'array_delimiter'); This is perfect, as it shows what I set on the form ...
2
votes
1answer
80 views

Form with two submission buttons

I try to create a form with two submit buttons and each button will use a different function: the default submitForm function and a custom submitFormEndSession function. So I have this code: class ...
-3
votes
1answer
30 views

InvalidArgumentException: Class ... does not exist in custom configuration form [closed]

I create configuration form, so that I could dynamically set the API key for my custom weather module. But when I write in the url address http://drupalsite/admin/config/services/weather/settings I ...
0
votes
0answers
15 views

Over-ride entity delete button permission

created a Form View mode and some custom permissions (pre node, based on a user list field in the node). I want a user with that permission to be able to delete the node as well, and have added a ...
0
votes
0answers
17 views

How to nest fieldsets?

My goal is rather simple, I need to group several fieldsets in a fieldset like in the image below : I tried with the following code : public function buildPaneForm(array $pane_form, ...
0
votes
0answers
14 views

Why is not printing the Table?

I have this code: $form["noah-search-container"]['actions'] = [ '#type' => 'button', '#value' => $this->t('Buscar'), '#ajax' => [ 'callback' => '::noahSearchQuery', ...
0
votes
0answers
45 views

Batch Error: Using $this when not in object context, so Can I call batch method in non static way?

The existing code when a form is submitted I execute this batch : /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $node_titles = ['node1', '...
0
votes
1answer
40 views

specific submit handler to user form

I have a submit handler to the user form. It redirect the user to a specific page. use Symfony\Component\HttpFoundation\RedirectResponse as RedirectResponse; /** * @file * Primary module hooks for ...
1
vote
2answers
86 views

Confirmation message on comment submission

When a comment is submitted, no confirmation message is shown and I would like to achieve this. I want to show the following message. Your comment has been added for review and approval. I tried ...
1
vote
0answers
28 views

Can't save value of custom datetime field

I'm reaching out because I just can't find out why my custom datetime field isn't saving its value after I submit. Context: I've created a field containing two datetime fields. I will use it to add or ...
0
votes
1answer
40 views

Time spent with custom module

Can anyone help me with this, I want to activate time spent module on my custom form module, and store the time spent on a field on my form. I think that I could do it on the file timespent.module ...
0
votes
0answers
14 views

Vertical tabs custom form Drupal7

I have a question to discuss about Vertical tabs on Drupal7 when we use it on custom module to make a form. Can we use a vertical tabs on a another vertical tabs? I know how we do to make a one ...
3
votes
1answer
57 views

How to not split select list by content type

This is about the regular select widget that you can choose in the Manage form display page. If this widget is linked to an entity_reference field allowing several bundles to be selected; then you end ...
2
votes
1answer
39 views

How to alter the view behind a select widget in a regular node edit form

I have an entity_reference field in a content type: field_node_ref In the field definition, it can reference all the nodes of a given type. The widget used for this field is a select widget Depending ...
0
votes
1answer
18 views

Add default value to existing field

I have tried to add default value to an existing field using hook_form_alter() but it does not work. Below is the html of the fields <fieldset class="js-form-item js-form-type-textfield form-...
1
vote
1answer
118 views

Adding an "Accept Terms" checkbox on User Registration form

I need to add an "Accept terms and conditions" checkbox onto a user registration form. What is the best way to do this? Also, it seems odd to me that there is no easy way to use radio ...
0
votes
0answers
14 views

custom module form radios fields & ajax problem

I have a custom form, that iI develop on a custom module to get some fields from a content type with an entity reference. All is good, I can get all information, and I can save the chosen value on a ...
0
votes
0answers
18 views

Altering user_admin_account and user_register_form

I'm pretty new to Drupal and I'm trying to build a Drupal 7 custom module to alter the user listings table in admin/people. I would like to display the first and last names of the users. I've already ...
0
votes
1answer
40 views

Validation for radio inputs don't work for me

I'm building a form with the drupal forms api. Validation works well for all my other fields. But I've started to try and work with radio buttons too now. It doesn't matter if I click on a radio ...
-1
votes
1answer
47 views

Formatting date field with the Form API

Hi there I'm using drupal 9.x and the forms api to generate a dynamic form. Altough I'm living in the Netherlands where the date format standard is 'dd/mm/yyyy'. I've looked around on the internet for ...
2
votes
1answer
90 views

Block Settings inside Form

Please I need help with my code. I have a form and a block created programmatically. The block embeds the form to show it on the frontend. The block also has some settings (form preffix text). I want ...
1
vote
1answer
26 views

Place field in "Url Alias" advanced group section (path-0)

I'm trying to place my node field to the Advanced group - URL alias section. I'm doing it in custom hook_form_BASE_FORM_ID_alter(), where I'm trying to set custom #group like this: $form['my_filed']['#...
1
vote
0answers
24 views

Alter Inline Entity Form before saving

I am using the Inline Entity Form module so that I can create a content type B from content type A. I want to alter a field of content type B before saving the value. I tried to do this: function ...
0
votes
1answer
51 views

Use ajax to save modal / dialog form instead of page reload

I'm looking for a way to save modal & dialog forms through ajax instead of redirecting the user after the form submit. Ajax is quite unknown territory to me. I've found several interesting topics ...
0
votes
1answer
22 views

How do I add a field to a node form?

The goal is to set a default counter, but let people override it. The counter should be the biggest value of the field plus 1. Using an event subscriber, FORM ALTER event. public static function ...
0
votes
1answer
26 views

Pager element not showing on form

I have a simple tableselect element inside my form and the tableselect rows are populated using a pager as follows: $pagerLimit = 10; //default value if nothing is passed in $query = $this->...
0
votes
0answers
20 views

Drupal hubspot forms with Varnish

I have a Drupal 8 hubspot form built in a custom module which holds many fields among which a "Favorite Pizza" field coming from hubspot and this field is rendered as a required fieldset. ...
2
votes
1answer
28 views

Why can't some fields be moved within details element?

I am trying to move 2 form fields to the advanced sidebar: dismissible and status. Status was already part of the meta container and setting #group='meta' on dismissable also placed it there; but ...
0
votes
0answers
19 views

Custom validation multi value paragraphs : how to get weight value

I am validating a multi value paragraph field using constraints. /** * Implements hook_entity_bundle_field_info_alter(). */ function cnfpt_internet_entity_bundle_field_info_alter(&$fields, \...
0
votes
0answers
15 views

Custom validation multi value paragraphs: highlighting missing field

I am using constraint for the validation my multi value paragraph field. I can correctly implement the different validation rules but I haven't found out how to highlight only the erroneous field(s). ...
0
votes
1answer
51 views

Build custom form with entity form field

I have a feature to migrate from Drupal 7 to Drupal 9. This allows me to build a custom form made up of static fields, which I define in the code of my module, and fields dynamically retrieved from an ...
0
votes
1answer
18 views

Using both Drupal Core Contact Form and contributed Webform module

I have a Drupal 8 site already utilizing core Contact Form. However, we now need a more complex form and thinking about installing a contributed module: Webform (https://www.drupal.org/project/webform)...
0
votes
0answers
31 views

Set ['#default_value'] of taxonomy term reference field via hook_form_alter()?

Here's a different question with the same taxonomy term reference field I mentioned in my previous question. Users with Administrator and Coach roles are granted permission to register Student users ...
0
votes
0answers
28 views

Controlling dropdown field visibility using #states API for dependent dropdown

I have the following setup. dropdown_one [ '#type' => 'select', '#title' => $this->t('Dropdown one'), '#options' => $dropdownOneOptions, '#empty_option' => '---', '#...
-2
votes
1answer
36 views

How to add anti csrf token to the forms (No Anti-CSRF tokens were found in a HTML submission form.)

When i was testing my drupal 9 website for security i got the error as "No Anti-CSRF tokens were found in a HTML submission form." solution is given as "use anti-CSRF packages such as ...
0
votes
1answer
35 views

entity_form how to programmatically add references and update the form visually (entity_browser)

I´m having an fieldable entity with a reference field to paragraphs field_paragraphs and a paragraph_type with a reference field to content_type event field_events. What i am trying in the entity form ...
0
votes
1answer
38 views

How to retrieve #tree values inside a multiple containers?

I am using Drupal 8 and I am creating multiple forms that are made of a #tree hierarchy. I am retrieving the value of the "first name" from the #tree using the below code and it doesn't get ...
2
votes
1answer
73 views

How to return an XLS file to download on form submit

I am trying to create an XLS file and send it to the browser on a form submit but I cannot figure out how to do it. I am using XLS Serialization module but I'm open to all other suggestions. With this ...
0
votes
2answers
42 views

How to retrieve #tree values inside a form?

I am new at Drupal 8 and I am creating a module that has a #tree form. I chose #tree form to create multiple forms which has the same textfields and button. I came across one document in drupal about #...
1
vote
1answer
59 views

Render responsive image inside form fields programmatically

I am trying to figure out how to render a responsive image programmatically inside a form field. I am doing maintenance in a code on my current job, and sometimes there are form fields using the '#...
-3
votes
2answers
35 views

How to fill a form field of type fieldset with values from an array

How can I fill a formfield type fieldset with more than one markup value from an array? foreach ($drugis_postgis_connection->tableNames() as $table) { $form['tables'] = [ '#type' => '...
0
votes
1answer
43 views

How can I filter the path aliases by node id?

On this page admin/config/search/path, we can only filter the results by URL alias. I want to filter the results by node id as well? How can I do that? It is not possible with form alter. As the ...
0
votes
1answer
65 views

Throw error for required field in hook_form_alter?

I have a node type that can be created by authenticated users. In the node create form, I added a terms-of-service checkbox via a form hook like so: function themename_form_alter(&$form, &$...
0
votes
0answers
36 views

How to create similar multiple forms using a button?

I am using Drupal 9. I am creating a module that has a form with a button that will re-create another form similar to the first one. These is my code. public function buildForm(array $form, ...
1
vote
0answers
29 views

Register form block into modal

I want to display the register form in a modal. For that, I created a custom plugin block which returns the rendering of the form register. /** * {@inheritdoc} */ public function build() { $...

1
2 3 4 5
134