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
0
votes
0answers
16 views

Menu options missing in node form

In Drupal 8, despite the fact that there is a menu set for the content type, menu options are not showing in the node form. I have disabled some menu modules in case they were interfering, but with ...
-2
votes
0answers
16 views

Send Data from contact form to drupal [on hold]

i have a contact form in webpage lik this and i want to send data from this form to website drupal , the question this is possible or not ?
0
votes
0answers
22 views

Pass rendered markup to redirect route

Drupal 8.7.x I have form that passes the outputted data into a template. This template with the data gets rendered into a string like so: : public function submitForm(array &$form, ...
0
votes
1answer
24 views

How to pass rendered form results to page

Drupal 8.7.x I have a custom form that currently replaces the form with the output of the form like so: CalculationForm.php public function submitForm(array &$form, FormStateInterface $...
0
votes
1answer
37 views
+50

Drupal 8 inline Entity Form Ajax Event (Add another item) Message

In Drupal 8 inline entity form is there a "form_alter" or "submit handler" or some type of ajax callback for when a user clicks "add another item"? What I would like to do is display a message to the ...
0
votes
1answer
17 views

How to deny access if url is changed manually?

Maybe the way I'm doing this is not the correct one but here it goes. I have a page in my site where I have a form. In that form I have a select list that I fill with user ids from a query. So for ...
-3
votes
0answers
26 views

Alternative to FormBase to create D8 form [on hold]

Is it possible to use Symfony to create Drupal 8 form api compliant forms? My project needs to generate multipage forms dynamically. While I have successfully created a class which extends FormBase ...
0
votes
0answers
36 views

Drupal Queue Item Id in ProcessItem Function [closed]

I developed one custom module which will display a list of entries from my custom table. Now i need to add two buttons on top of the grid as "Clear out Unpublished" , "Clear All" Clear out ...
0
votes
2answers
74 views

Paginated form with ajax checkboxes throws “The specified #ajax callback is empty or not callable”

Using Drupal 8.7.7 I have a form which consists of a paginated table of users. Each user row has a checkbox element in the form with an ajax event attached. This is essentially to allow me to store ...
0
votes
1answer
37 views

Create nodes unlimited times

I've been trying to ajaxify the node creation form, the purpose? Save the node and remains in the node creation page (Done) If the user clicks the save button again save a new node The second point ...
2
votes
1answer
23 views

How can I theme the markup for the labels in a set of radio options on a specific form item?

Given this form item defined in a custom module; $form['my_items'] = [ '#type' => 'radios', '#title' => $this->t('Items'), '#options' => $optionsSet // array of options pulled from ...
0
votes
0answers
15 views

Custom submit handler for views exposed filter not working

I am trying to alter the views exposed form filter submit handler by using modulename_form_views_exposed_form_alter(&$form, FormStateInterface $form_state, $form_id) { if ( $form_id == '...
0
votes
0answers
23 views

How can I get the day count between a Date field and the current system date?

I have a content type, and there are two fields(Joining Date, and Day_count fields). Question: I have to calculate no. of days between the Joining date and Current date(Ex: Joining Date field ...
0
votes
0answers
40 views

Block not showing in controller generated tables Drupal 8

I have created a custom module that should show my custom block above the controller generated table. The block shows in other pages but not in the page where it is supposed to show. Found out that it ...
0
votes
1answer
22 views

The security danger of publicly exposing an upload field

On older drupal 7 websites I once faced security patches for the webform module, because file upload fields were considered insecure. There was en exploit where people could end up uploading .html ...
0
votes
1answer
42 views

AJAX form doesn't use ajax until cache clear

I'm defining an ajax form in my custom module (#ajax for submit). It is shown in custom block. But it works fine only on cache clear (on Drupal clear all caches or on ctrl+r in chrome). If I just use ...
0
votes
0answers
17 views

Dynamically created elements trigger wrong submit handler post AJAX event

I've found that dynamically created submit handles will adopt the first declared submit function in a form after an AJAX event has been processed. Demo code: <?php function form_test_main_form($...
0
votes
0answers
9 views

How to check validation while importing file CSV file for feed importer - Drupal 7?

I'm using Feed Importer to import Contents from CSV file to Content types(Like Bulk Import). Now i have to do validation in that file while importing like Required field, Unique fields, some ...
0
votes
0answers
15 views

how to call Manage From Display for a content type in page controller [duplicate]

I have created a Form Mode and configured the Form Display as below image Now, how do I call this form display in custom module controller.
-1
votes
0answers
20 views

How to create bootstrap barrio modal with form?

I am using Bootstrap Barrio theme in Drupal 8. How do I create a Modal (only Bootstrap modal not Drupal's Administrative modal) that has Form and when submits the form it store it a Content.
0
votes
0answers
14 views

Separate page (non-administrative) for adding content for Non-Admin User with few fields

I have a Content type Product with fields Title Tags Picture (File) Status (Active, InActive) (For Administrator purpose) I want the other type of Users to add Product content without using ...
0
votes
0answers
10 views

#states property in field cause multiple values not work in form with paragraphs

Hi i have an issue with form How do i fix that? I have created custom Entity and few bundles in bundle i'm using reference fields one of them is from Paragraphs with multiple values. i needed ...
1
vote
1answer
33 views

How can I hide a field in the node add form but it unhide it on the node edit form?

I'm having a content type in that I want a field "Status" to be hidden in add content form page(I'm setting default value in that add content). Now I want that field to appear in edit form page of ...
0
votes
1answer
14 views

Changing the html and order of system fields(pass/email/locale/etc) of user edit form

I have changed a number of forms accessible by users to fit a certain style. To do this I used an #after_build function that adds prefixes and suffixes to fields, as well as a bit of javascript. This ...
0
votes
0answers
19 views

How do I prevent NaN from appearing in the drupal form field?

For this field, if a user enters a space and leaves the field, the field fills with NaN, any idea how I can prevent that from happening? if (variable_get('variable', DEFAULT) === 1) { $basics_form['...
0
votes
1answer
24 views

Is there a way to create hierarchical taxonomies checkboxes?

I have an issue where I want to keep sub category inside a parent category. Say, for preferred vehicle I want a checkbox like this in node creation form []Car []Volkswagen []Toyota []Bike []...
0
votes
0answers
11 views

How can I set a Custom Field's label to 'visually_hidden' by default?

So I created my own field plugin, and I wonder if it's possible to set a default value for the display option. Obviously, there's no way to set this in the field formatter, and I don't see where I ...
0
votes
1answer
29 views

Syntax to use form_alter with array in name attribute

I would like to modify some custom fields with form_alter in a contact form. I know for example how to change placeholder for this "name" field : Note : I removed all the unnecessary html elements ...
1
vote
3answers
74 views

Set label of $entity programmatically in a custom form

I need to change the label of a custom content type programmatically. I've looked around but I couldn't find a solution. This is my custom form: class GroupContentForm extends ContentEntityForm { /...
0
votes
0answers
27 views

Disable validation when previous button is pressed

I have a multistep webform with required fields. The problem is that when I press the "previous"button in order to go to the page before the validation triggers and does not allow me to change the ...
0
votes
1answer
41 views

How to save the webform data to custom table?

I designed a student registration form using webforms module. My requirement is to save data from the form to table student. How can i achieve this? Is there anyway to mention this in configuration ...
0
votes
1answer
26 views

Hook form alter to check date field is empty or not

First of all I'm new to custom modules, I'm using hook_form_alter to do some custom validation, in the middle I have to check if a date field is empty or not, if empty I will display an error message. ...
0
votes
0answers
10 views

How to Create a Form with Ajax Output External to the Form?

What I want to achieve is: A form with a number of selects / textfields A div external to the form that contains information pertinent to the form's current input (i.e. not contained in the form ...
-1
votes
1answer
64 views

How can I access individual form elements for theming?

I have overridden the default user login form in Drupal 8 using a different template in my sub theme, but it isn't of much use because when I access it in twig template, all I can do is <form {{...
0
votes
0answers
21 views

How to use FormBase with form_alter hook?

I am trying to edit the node creation form in order to add multiple 'tableselect' fields in it. My module adds options in a select field and add an ajax callback triggered by the 'change' event of ...
0
votes
2answers
34 views

Rendering plain HTML in a form

I have HTML markup which is externally generated but I need to display in a form. I've got the following code in a form controller: public function buildForm(array $form, FormStateInterface $...
0
votes
0answers
16 views

When rendering a custom form, how do I use <button> instead of <input type=“submit”> for the button #type? [duplicate]

I have a render array for my custom form, which acts as a "Like" button for articles (but with custom functionality for our client). The button is defined like so: ... $form['like_btn'] = [ ...
0
votes
0answers
18 views

How to active conditional field function in DEPENDENT field when DEPENDEES field is autofill

I having an issue with conditional fields module, My Form: I have a field(Type)(Drop-down) that will be auto filled based on a entity reference field and another fields(Start and end Date) that i want ...
1
vote
0answers
15 views

8 - How can I update the entity reference fields of the form when I close the modal?

How can I update the entity reference fields of the form based on selection in the modal dialog when I close the modal ? I have a form and users starts fill the form. Then click on choose address ...
0
votes
0answers
27 views

How can I theme the login form?

I new in Drupal 8 and I have an a problem, i want to change de look of my user_login_form, reading about that i knew that i could use the hook_form_alter for my purpose but I can't access the form ...
0
votes
1answer
36 views

Access table form field's data from submitForm

I'm building a custom form and it display well. My form has a table type field which I can't manage to access from the submitForm method. public function buildForm(array $form, FormStateInterface $...
0
votes
0answers
13 views

Override form field #value after ajax request sets it

First of all, here is the code: /** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $form['join_newsletter'] = [ '#type' => '...
2
votes
1answer
50 views

Is there a way to run hook_form_alter after themes implementation?

I'm using the material_admin theme, which has a hook_form_alter() implementation. I see that my module's hook_form_alter() is executed before the theme hook. Both hooks are editing the same form ...
0
votes
0answers
14 views

Set and retrieve cookie in a form [duplicate]

How do you set and retrieve a cookie from a custom form in Drupal 7? I am trying to set and retrieve a cookie containing form_state in a custom form. The form is a multi-step form. My intention is to ...
0
votes
0answers
24 views

How do I load a file in a managed_file field inside an edit form?

I'm building a custom module (Drupal 8) which implement new elements I called components. I have a component creation form which has a managed_file field which works well, it submits, save my image ...
0
votes
0answers
43 views

ContentEntityForm buildForm method parent out of memory

I have the following issue with my form class that extends the ContentEntityForm class. When calling the parent buildForm which is needed my system runs out of memory. /** * {@inheritdoc} *...
1
vote
1answer
22 views

Webform Select Element Optgroup / hierarchy

Hello fellow Drupal users, I have created an advanced HTML element in my webform. When the form is submitted the advanced html element reverts back to the default setting, which in this case is option ...
0
votes
1answer
41 views

Show form errors before opening AJAX modal

I have a form that adds a product to the cart. The form uses AJAX to open a modal when the form is submitted. I want to show form errors (if any) before the modal opens and avoid opening it if there ...
0
votes
0answers
34 views

Private file upload using core's contact module

I am using the core contact form module for user applications. I have set a private file upload directory in settings.php. When the user submits the application form I require them to also upload a CV ...
0
votes
1answer
28 views

Form is not submitting after ajax callback

I have a form which has a checkboxes field. This field has an ajax callback attached $form['checkboxes'] = array( '#type' => 'checkboxes', '#title' => 'test', '#ajax' => array( '...