hook_form_alter() is the hook implemented by modules to alter the forms implemented by other modules.

learn more… | top users | synonyms

0
votes
1answer
25 views

Can I use hook form alter to add an attribute to a webform field?

I am trying to use hook form alter to add an onchange attribute to a select field but it is not working. Is it possible or is there something wrong with my module code? function ...
1
vote
0answers
34 views

Set user profile fields that are not visible on registration form

Very new to Drupal, first of all. I'm working on a custom module for user registration (we're still in Drupal 6) that I'd like to do a few things: Geocode the user-supplied zipcode to get a ...
0
votes
2answers
28 views

Use CAPTCHA module on a custom HTML form? (no use of Drupal Form API)

Is it possible to use the CAPTCHA module on a custom HTML form created in a content page of a Drupal 7 site? I am not using the Drupal Form API or webform modules. The form has the following code: ...
1
vote
2answers
29 views

In form alter what is the different way of hiding fields and what is the difference between them?

I am currently using the following code to hide the fields in the form 1. $form['field_name']['#access'] = FALSE; 2. hide($form['picture']); 3. unset($form['picture']); 4. ...
0
votes
0answers
9 views

Multi-column checkboxes render the checkboxes as columns

I've found this module https://www.drupal.org/project/multicolumncheckboxesradios to display a long list of checkboxes in columns. I've altered the form to add the required parameter as the module ...
0
votes
2answers
32 views

Add html markup to Drupal Webform

I want to extend the simple text the Webform module allows for radio buttons to include HTML markup. The Drupal Options Markup module purports to add markup to the text for radio buttons. It does, ...
0
votes
0answers
63 views

Adding group content to an organic group doesn't persist after submit action for hook_form_alter

In the submit handler I wrote for my implementation of hook_form_alter for a node edit form, I can successfully add a group content node to an OG using og_group() - og_is_member() returns TRUE after I ...
0
votes
0answers
18 views

Save node and pass field value to registration form page

imagine a homepage with only one field and a save button. I would like anonymous users could fill this field and after clicking on the save button, the user is redirected to user registration page and ...
0
votes
0answers
29 views

Add another set of field collection to the $form in mymodule_form_alter

I am working on custom quiz module, where we have Multiple choice questions. We have created separate field collections for Question and it's options. Author can add unlimited number of question and ...
1
vote
1answer
15 views

Adding a button to a form that links to an external URL

I am trying to add another button to a user login form. I am able to get the button to show up, but not to link to an external URL (example.org in the code below). Code I am using is below: ...
0
votes
1answer
19 views

Drupal 7 Adding additional fields on user registration page, specifically first name and last name

In Drupal 7, what methods are there to add additional textfields to the user registration page at /user/register? I mainly want to also get their first + last name during registration. There doesnt ...
0
votes
0answers
27 views

form_alter and #element_validate inside .module file

Inside my .module file, I have created a hook for alter register_form and add a password field with a custom field-validation: function xenforo_form_user_register_form_alter(&$form, ...
0
votes
0answers
5 views

Problems with a “filter field options on term refernce” ajax callback

I'm having problems with a "filter shops on section" ajax callback, when field_sections (term reference with unlimited values) changes field_shops (entity reference) should show all shops with the ...
0
votes
1answer
25 views

Adding a validation step via hook_form_FORM_ID_alter()

I am trying to add a custom validation function to an existing form. I am using hook_form_FORM_ID_alter() to edit the form. I am then adding a new function to the #validation array. When I use dpm() ...
0
votes
0answers
82 views

Modal form FB login fail redirects to page with Ajax response

Modal popup contains: Login form + Facebook login button. Both the login methods(Login form + Facebook button) work fine for users who's account is active. FB login button is implemented using fbauth ...
0
votes
1answer
31 views

Can we add a new column to field collection in edit form?

I created a topic before with this question, but i write another to be more exact on what i want to do. I have an entity with several field collections and in this field collections, several fields ...
1
vote
2answers
40 views

How do I rewrite the ID of an exposed filter field element?

I am desperately trying to a way that I can rewrite the ID of an exposed filter field element. I've gotten so far as to set up hook_form_alter where I can get the specific $form array that I need. ...
0
votes
2answers
42 views

How to autofill text fields in form?

I have two pages, on the first page, the user types in an ID. Using hook_form_alter, I then override the submit function and add my own functionality that will then grab information from a database ...
0
votes
0answers
125 views

Dependent multiple selection drop down in drupal form - illegal choice error

I'm new to Drupal , in my project I have 2 multiple select drop down box. I don't know how to do dependent multi select drop down action in drupal form alter function using ajax. Single selection ...
1
vote
1answer
25 views

How do I pull a field value from a form field in to my inline entity form?

I'm trying to do something which I would think is fairly simple, but I'm just stumped right now, hoping somebody can help. I have an entity called 'page', and in that entity I have inline entities ...
0
votes
0answers
17 views

Override the “options_list_callback” value for a specific taxonomy term reference field

I want to know if it's possible to alter some term reference fields and use a custom method instead of taxonomy_allowed_values. I have tried this with no success function ...
4
votes
1answer
57 views

Get entity id in hook_form_BASE_FORM_ID_alter()

I am working on porting a D7 module to D8. As in Drupal 8 all things are represented as entity, menu items are also represented as entity. Now I added a hook_form_BASE_FORM_ID_alter() implementation ...
0
votes
1answer
26 views

Alter label with token

I am trying to build a questionnaire that simply replaces (alters) the label of a list-field. I´m doing so by replacing a token from views (embed) and using a hook_alter_form function in an separate ...
3
votes
1answer
37 views

Image field - 'Number of values' is not showing up in admin form

Something's very wierd with my existing Drupal 7 setup (current Drupal version, set up in early 2013, custom Zen Subtheme). When I create a new Content Type with a new Field Type "Image" this 'Number ...
0
votes
1answer
79 views

Custom submit button callback overrides default callback?

I am trying to accomplish the following functionality: I have a profile2 registration form to which I have added a custom form element (just a submit button) using hook_form_alter(). The submit ...
0
votes
1answer
34 views

adding data attribute to option value in Drupal 6

I have a form, like this: $form['my_case_type_list']=array( '#type'=>'select', '#title' => 'Issue Type', '#options' => $my_list, ...
0
votes
2answers
47 views

Make form to show multiple field widgets with predefined values

I have a node form with multivalue field (cardinality unlimited). I need to show user 3 widgets if this field with predefined value (like shown at screenshot). At screenshots I show the current form, ...
0
votes
2answers
80 views

How to soley wrap the <input>-field in a custom <div>-wrapper in Webform 4.x?

I've a fairly simple question. Due to a given CSS I need to wrap the <input>-field (as well as <select> or <textarea>) of webform-component with a custom <div>-wrapper. Change ...
2
votes
1answer
18 views

Commerce module: Why this commerce_order_ui_form_commerce_order_ui_order_form_alter won't work?

I have this commerce order, and I want to hook into it when an administrator review the order (edit it to set it as complete, canceled, or whatever state). I want at that moment to use a specific ...
0
votes
0answers
14 views

Values on select list are not getting saved on submit

I have a select list(Text) with empty (0) values. I'm setting the #options programmatically on mymodule_form_alter. Everything s is being set for the #options, but when i submit the form, the value ...
0
votes
1answer
59 views

Using #states to disable a field collection field

I am trying to disable a date field's second value, inside a field collection, but it isn't working. My hook_form_alter has this: ...
0
votes
0answers
25 views

Drupal 7 Webform add a select field via alter

I am aware of adding fields via the Drupal form API. I am wondering how can I add a field to a Webform via my custom module. In this case I would like to add a select field whose value I would like to ...
0
votes
1answer
58 views

hook_form_alter isn't working

I've been trying to insert a placeholder for my search-bar, so in my page.preprocess.inc I call hook_form_search_block_form_alter(), then specify the form's array, and create the placeholder array, ...
0
votes
2answers
40 views

How to alter a form's name attribute

I'm trying to override the Drupal Login form. I have been able to unset and modify pieces of it, but the last thing I am struggling with is the name attribute on the submit button. Currently, the ...
0
votes
0answers
31 views

Checkboxes not rendering after changing options

I'm developing a module that alters the node submission form to accomplish the following: The user selects a value from an autocomplete field The user clicks a button (add_courses) that shows a set ...
0
votes
0answers
34 views

Commerce Product Add On HTML Wrapper For All Linked Products In Add To Cart Form?

I'm using the Commerce Product Add On Module, which uses Entity Reference to insert 'optional' products into the Add To Cart form in the form of checkboxes. I want to create a DIV which encapsulates ...
0
votes
1answer
44 views

How to pass default values on node form through form_alter when using confirm_form?

My confirm form should consists part of node form but with disabled fields. I mean after I submit node form I rebuild it and append confirm form in hook_form_alter()(Before it I change submit callback ...
2
votes
1answer
22 views

How to unset _none option inside field collection?

Normally, in a node form you'ld unset the _none option like so: function MYMODULE_form_FORM_ID_alter(&$form, &$form_state, $form_id) { ...
1
vote
1answer
44 views

Set entity reference field in form to readonly

I am building a custom module to set default values for entity reference fields. To avoid overwriting these defaults, i would like to set the field readonly. While I got the defaults to work, setting ...
0
votes
0answers
18 views

Advanced hook_form_alter #required option

I have a form, build by content type with not required field. To this form i added additional submit button with custom submit function (using hook_form_alter). So the form looks like this ...
1
vote
0answers
20 views

Updating multiple elements in Form Ajax Callback [duplicate]

The Form In a Drupal Form I have (amongst other elements): Two select lists: Retailers, Products. One Table select: Selected Products. Two buttons: Add, Remove The Functionality I want: The ...
0
votes
1answer
77 views

hook_form_alter Add wrapping div around label and input

Using hook_form_alter, for each field I want to wrap a div around the label and the input, leaving the help text (description) separate. Can hook_form_alter do this? Seemingly I can only add prefix ...
0
votes
0answers
18 views

Modify Userpoints List FormTo Show Entity ID?

How does one modify the List used to display userpoints? eg. http://example.com/user/123/points I'd like to be able to modify that (table) to display the Entity ID (the source transaction id). ...
0
votes
0answers
71 views

Unable to alter Drupal 7 webform 4 text and select field values after form post

I have set my webform to reload on submission, then I am checking if the form was posted and on that basis alter the form value. I tried the following: Set Default value to %post['company'] Manually ...
0
votes
1answer
92 views

Using hook_form_alter to enter placeholder in mailchimp signup fom

For the signup form I'm using the Mailchimp Signup module. The idea is to hide the label, which I did using the unset(); function, and put an a placeholder in the input field where people enter their ...
0
votes
2answers
69 views

How to change the field label on my registration form? Drupal 7

On the default registration form, I want to change the Username label to 'Request your username' I tried putting this in my template.php:: function mymodule_form_alter(&$form, &$form_state, ...
0
votes
1answer
78 views

ajax modified form drop down doesn't save

I have used form_alter to add a ajax callback to an element to my form. When the user chooses an option, it creates dropdown options for the other field. However, while this works fine for changing ...
0
votes
1answer
35 views

Add Nested <ul> List into $form

I have something like this. How can I make $upload_items be a nested <ul> list under Upload examples Something like <ul> <li> Upload Ex </li> <ul> ...
1
vote
0answers
85 views

How to set a default value for Simple hierarchical select?

I tried to implement hook_form_alter in order to pass default value to Simple hierarhical select views exposed filter. function mymodule_form_alter(&$form, &$form_state, $form_id) { $tid = ...
1
vote
2answers
62 views

How to add css class to these form fields?

I wan to be able to add certain css class to all the text fields in my content edit forms. here is a picture of what i can see using Devel: Those arrays under the "Und" are for the fields I want to ...