Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

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

Tableselect with return new response doesn't work

I'm newbie in drupal and I want to create contact list with dynamic search on ajax. I want to ajax load my tableselect. So I use return new Response(render($form)); where the form is tableselect. I ...
0
votes
1answer
512 views

Programatically Submitted Form With 'file' Field Throws Notice

This seems to actually be a problem in Drupal itself. In /modules/file/file.field.inc the function file_field_widget_form has a line like this near the bottom (just before the return statement): $...
0
votes
1answer
514 views

Is it possible to change the form submit handler from within a validate handler (need to redirect to another form depending on values entered)

I have an initial webform (based on 3.x of webform module/Drupal 7) that needs to redirect to a second form if yes is specified in a yes/no choice. Otherwise if No, the first form should submit ...
2
votes
1answer
43 views

How can I add a custom CSS class to checkboxes labels?

I'm using Drupal 8 with the Form API and the AJAX API, now I want to add a custom CSS class to every checkbox label, because I need to use the bootstrap custom checkboxes. PHP (slimmed): $form['...
0
votes
1answer
540 views

Update theme table using callback function in Ajax

I have two elements in my form: a select and a table element. Everytime onchange event is triggered on select element, I want to update the values in my table. I want to do query and change the values ...
1
vote
1answer
14 views

How can I get the checked attribute into Better Exposed Filters input type radios?

i'm having a BEF exposed filter representing a taxonomy, they're radios. It works well, but when i select a radio, it won't get in its HTML tag the property «checked». I guess the selected value of ...
0
votes
1answer
21 views

Redirect to view display after form submission

I'm using a form_alter hook to add a custom submit callback. I want to redirect the user to a particular page display of a view. However, I'm having trouble figuring out how to specify the path. In ...
0
votes
1answer
482 views

How to display the input box next to the label in a form?

My objective is to improve the look and feel of a form developed in Drupal 7. By default, I have (as an example): Name (label) BLANK INPUT box (below the label) How to display the label and input ...
-1
votes
0answers
11 views

submit button does not respond after creating custom theme in drupal 6

I am trying to implement a custom theme. However, after creating custom theme my submit function stop inserting data into the database. Any suggestions would be appreciated. hook theme-sdbpireq....
5
votes
4answers
2k views

How do I find a Form_ID for hook_form_FORM_ID_alter?

I want to alter the form for a content type I created for videos. The type is called Videos. How would I use hook_form_alter to alter the form to create the content?
1
vote
0answers
16 views

How to achieve dependent filters programmatically for views exposed form?

I have a requirement like Category and Sub-category should display as dependent filters. When I choose a Category next related sub-categories should show up in another field. These mapping is done in ...
0
votes
1answer
20 views

Drupal 8 - Add custom HTML with script to embed on a page as block

I need to add a custom form that has scripts and styles into a page as a block. Its dynamic, so I couldn't attach the scripts (#attached) as libraries. I just need to place the contents as is. $...
0
votes
1answer
713 views

Table Pager Rendered in an Ajax Callback Shows White Page

I have the callback function below that renders a table with a pager. Every page of the table is 20 rows. Below is the code: function myid_print_all_submitted_id_callback($form, &$form_state){ ...
0
votes
0answers
21 views

How to redirect a module button to a specific external Url [duplicate]

I'm trying to make a button type to redirect in an external Url and I don't know how to make it. I already make the simple Form and I need help for make this function. I'm using Drupal 8 Thanks in ...
1
vote
2answers
94 views

How can I display a message when “add another item” on an Inline Entity Form Multiple field is clicked?

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

How to alter the search api views exposed form field value?

I have a search api view. Which has an exposed some exposed filters. The exposed filters contains postal code, city and latlong field. The user will enter the city and postal code and then in the ...
1
vote
1answer
472 views

How to update one select element via Ajax when using node_add

I have just created a new content type called pieza_musical. What I just want to do is update one select element via Ajax depending on another select choice, a dependant select. I'm altering the ...
0
votes
1answer
343 views

file_field_widget_form error when programatically creating nodes

I have a simple routine which I use to create nodes. The logic is something like this: function make_node($node_type, $field_data) { foreach ($field_data as $k => $detail) { $field_key ...
1
vote
1answer
461 views

Form is not being rendered in template file

I have tried drupal_render,drupal_get_form etc for rendering the form,but the form is not being rendered. Is there any error in code or else what else should i add to the code so that it works. ...
-1
votes
1answer
35 views

entity_autocomplete, multiple users

I would like a form element able to select multiple users. $form['forward_users'] = array( '#type' => 'entity_autocomplete', '#title' => t('Forward to these users (if multiple, select and ...
3
votes
1answer
443 views

Custom form values in hook_form_alter not available in custom validate function Drupal 7

I'm modyfing a node form to add a few extra fields. On submit, I need to program some extra logic to these values then save them to the node object. function module_form_alter(&$form, &$...
0
votes
1answer
499 views

Redirect to custom error page if node submit fails validation

I've embedded a node/add form on my homepage for submissions but for caching purposes, I need to have any server-side validation occur on a different page instead of itself. I.e. If the form fails ...
2
votes
1answer
1k views

Alter views exposed form drupal 8 [closed]

I have a view that in that view I set up 3 exposed filter, all working fine. I need to set a condition to show the third filter option to a specific user, it can be checked according to the user role,...
3
votes
0answers
27 views

Can I access more information (user inputs) using delta index?

I am working on an edit form of a content type, which contains several related inline_entity_form, let's say ief1 and ief2. When I fill and submit ief1 and come to ief2, I need to access the input on ...
2
votes
2answers
415 views

How to show label instead of value in custom autocomplete drupal 8?

I was making a custom autocomplete field and it worked as in when I type 'a' it shows me all the list of fruits with letter 'a'. But when I click on any of the options. I see the autocomplete field '...
0
votes
1answer
29 views

Form state cache breaks dependency injection [duplicate]

I have a class that extends FormBase and there are 6 services that are injected into the class via Dependency Injection (DI). My problem is when I submit the form it says to a class property that ...
0
votes
0answers
10 views

How to check empty tableselect

I have a Drupal Form with a tableselect than is loading with some information of authenticated data. So the tableselect could be empty. Using Drupal Form #States, I am looking for a way for checking ...
0
votes
2answers
689 views

How to validate a form against a custom user profile field?

I unsuccessfully tried https://www.drupal.org/project/rules_forms for forms validation so I am writing my own little validation module. Basically, on node creation I want a validation against a ...
0
votes
1answer
502 views

Custom form callback

I created a custom theme. function test_module_menu() { $items['my-test'] = array( 'title' => 'My title', 'page callback' => 'test_module_page', /* callback function */ ...
0
votes
1answer
683 views

Custom form validation

I've created a custom module for populating a database and now I need to apply form validation to this form. I want a few different validation things to happen. I want to limit specific entries on ...
0
votes
2answers
694 views

How do I implement the login, register and “Forgotten password” forms?

I'm trying to implement the three Drupal 8 user forms : login, register account and forgotten password forms. I'm creating custom pages in my module for each one of them because I want to display ...
0
votes
1answer
484 views

Profile2 regpath move account email field, into profile2 form and handle submit

I have a profile2 regpath displaying my profile2 form, and the system default account registration form below it. I need to move the account email field up into the container with the profile2 fields. ...
0
votes
1answer
807 views

How do I throw values calculated back to buildForm()?

I am trying to throw back values that are calculated in submitForm() to buildForm(). How do I add more state values into it? /**  * @file  * Contains \Drupal\resume\Form\ResumeForm.  ...
0
votes
2answers
668 views

How can I dynamically disable a single required field from validation in a form?

This is an extension of this question: Need help with AJAX callback function for text field validation in form_alter I have a form with a Username autocomplete field (txn_user). The editors want to ...
1
vote
1answer
381 views

How do I replace part of a webform component label with a variable token?

I have webform component labels like this: Did [your pet] have any illnesses? and I want to replace [your pet] with a variable token? Do I need to write a custom module or can I do this by editing ...
0
votes
1answer
721 views

How to fetch/load a node form using jquery/ajax?

In my previous question, I asked on how to fetch views blocks, now I would like to do the same with the node form but somehow this is the code that almost worked for me: setTimeout(function(){ $('....
1
vote
1answer
606 views

Use hook form alter to change input type

I am trying to change the input type on an ubercart checkout form using hook_form_alter. I added an extra field using the uc cart extra fields pane module but there is no option to add e-mail - only ...
0
votes
1answer
164 views

How to change “New content” text in entity connect autocomplete edit/add buttons?

using entityreference autocomplete widget (field-widget-entityreference-autocomplete) with entity connect I have the buttons "New content" and "Edit content". How can I just rename them in "New" and "...
2
votes
3answers
532 views

create a custom form based on user fields

I created new menu item witch I want to insert a custom form to edit some user fields : $items['user/%user/edit-custom'] = array( 'title' => 'Knowladge', 'page callback' => '...
0
votes
1answer
755 views

Allow special characters in the Search Form

I can't search with any special character in the default search block form or in search API. Commonly used word like B&W (black and white) don't seem indexed up well, probably due to some encoding ...
0
votes
1answer
678 views

How do I check by default a checkbox from a checkboxes control after an AJAX call

I have the next form which behavior is: When you select an option from select control, different checkbox are load on checkboxes control. When you check/uncheck checkbox a message is showed on the ...
0
votes
1answer
406 views

How to show a custom form in a block?

I have a custom form which currently shows on a page. The form is submitted via ajax and the view embedded is also updated via ajax. I do not want to show the form on a page. Instead I want to show it ...
1
vote
1answer
639 views

Replace textfield value on ajax callback

1) Am i missing something here? it's not replacing the textfield value. 2) Also how do i replace if i have a multiple textfield and multiple button in a form. <?php function test($form, &...
0
votes
0answers
24 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 $...
1
vote
1answer
593 views

How do I remove webforms from content types?

Currently, our site is built so that anytime a specific type of new content is created, the page automatically includes a form required for the end user. Due to tracking issues we're having with ...
0
votes
1answer
21 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 ...
0
votes
2answers
80 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 ...
3
votes
1answer
522 views

How to add javascript after form was validated with ajax callback?

I created a simple form. How could I add JavaScript commands after form was validated? Why is it so hard do this? $form['submit'] = array( '#type' => 'submit', '#value' => 'submit', '#...
4
votes
2answers
1k views

Alter granularity in date exposed filter from Y-m to Y if only year is selected

I am trying desperately to get the following working: Goal: I have a views that displays a list of events. To this views is a date exposed filter attached, with granularity Y-m(year month). I want ...