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

learn more… | top users | synonyms

3
votes
1answer
24 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
24 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
12 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
38 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
31 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
15 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
8 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
28 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
8 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
49 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
30 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
12 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
19 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
26 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
20 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
28 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
17 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
18 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
41 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
17 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
29 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
38 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
34 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
55 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
29 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> ...
0
votes
0answers
39 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
51 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 ...
1
vote
1answer
40 views

How to change label pass field on registration form

I need to change the password field label on the registration form. Name and Email I changed through hook_form_alter and password does not work. Help me! $form['account']['name']['#title'] = 'Имя ...
0
votes
1answer
52 views

form_alter: Inline entity Form

I am using IEF and all is well...until I try ad implement hook_form_alter() and when I access the form via IEF UI (as opposed to directly modifying the entity) none of the changes I make appear to ...
0
votes
0answers
37 views

How to use theme functions in .module files?

I am trying to override theme_radio and theme_radios directly in MY_MODULE.module file. For this purpose I declared these functions: 1) /** * Implements hook_theme(). */ function ...
1
vote
0answers
38 views

Help with form select options and sorting of values

I have altered the log-in form to my client's specification and I'm having problems with the display and sorting. As you can see, I have a select list called Organization. That is the Username Text ...
3
votes
2answers
91 views

How to adapt #prefix/#suffix for each option in radio form using hook_form_alter()?

I need to modify the html code of radio buttons generated by Ubercart Attributes. So I want to do it using hook_form_alter(). If I dsm() the $form I need to change using hook_form_alter() I get ...
0
votes
2answers
38 views

how to modify and the location of modified hook_form_FORM_ID_alter [closed]

I am learning to add a checkbox to registration form about agreeing to terms of use, found in modules/system/system.api.php, line 1708 I found an information here in modifying the ...
1
vote
0answers
21 views

hook_form_alter node menu and path settings

I have 2 problems which I have been trying to solve using hook_form_alter. I need to have the Provide a menu link, Indicated in the image below, checkbox selected by default on particular nodes. I ...
1
vote
3answers
65 views

Hide the Drupal /user/register form from spam, but leave open registration to Commerce/Ubercart

Commerce/Ubercart require account creation to buy product. That's fine - I want that. But I do not want user/register open to the public. Efforts to use Honeypot/Captcha/Mollom are still letting in ...
0
votes
1answer
24 views

using hook_form_alter on a same form from 2 different modules

How will a predefined form behave if we have two different forms that implement hook_form_alter? I would explain my question by an example, because currently I got a crash on it: I have a predefined ...
0
votes
1answer
53 views

validation of text box and checkbox

I am trying to validate the form. I have one hidden textbox and one check box group. field_institute_event - represents checkbox group. posted_student_list - represents hidden text box. If both ...
0
votes
0answers
39 views

AJAX not works (added in form_alter hook) in a view via views_embed_view

I have a view with a form (this is a commerce card - commerce_cart_form). I have added some AJAX to this form with form_alter. When I open this view direct by path - all works fine. But when I open ...
1
vote
1answer
86 views

hook_form_alter function to make field visible and required?

I'm trying to build a hook_form_alter function to make field visible and required. The form is the checkout form at http://example.com/en/checkout/33 The targeted field are Customer Profile Billing ...
1
vote
3answers
166 views

How to set a value for date field

I need to set value for a date field with type datetime in hook_form_alter. I tried with below codes. But it is not worked. $form["field_event_date"]["und"][0]['#default_value']['value'] = ...
0
votes
0answers
61 views

Form wont submit using AJAX when logged out

I am trying to submit the Add To Cart form using AJAX, I have altered the form like so: function ajaxcart_form_alter(&$form, &$form_state, $form_id) { if(strstr($form_id, ...
0
votes
0answers
25 views

form_alter hook in a ctools content-type plugin not called

I'm writing a ctools content-type plugin to use it as a panels pane. In my plugin code I try to use the form_alter hook at render for the login_form (not for the edit forms). But the hook seems not to ...
0
votes
2answers
138 views

Form submit handler not working

I'm developing a pretty basic module catalog_request that creates a form. I'm replacing the form's default submit button <input ..type="submit" /> with a <button ...>click</button> ...
1
vote
2answers
109 views

How to modify a term reference autocomplete field

I am using a term reference field but the widget type is autocomplete term widget. This term consist of many levels as parents and child. In the form I need to display only the child terms(only the ...
0
votes
1answer
28 views

Need help on adding options to $form via select field

I altered the username field in login block into a select field and now I'm trying to filter the usernames by their user roles via another Select Field. function design_form_alter(&$form, ...
0
votes
0answers
94 views

Facet API - Rewrite facet items via callback function

I'm trying to rewrite the link text in an Apache Solr facet block, specifically the one to drill down by bundle/content type. By default the block displays the human readable name of the content type. ...
0
votes
1answer
57 views

Change Login Form:Username to Select Text

Is it possible to change the login form? Specifically the Textbox for username to select text? Let's say I have 4 users named: User1,User2,User3,User4 and when select text is clicked. All users will ...
0
votes
2answers
109 views

Hook Form Alter Specific Node

I want to put a hook to a form on one specific form that I created. Based on Node ID. The code i currently have is . function jhumobileform_form_alter(&$form, &$form_state, $form_id) { ...
0
votes
2answers
37 views

Form Alter Foreach Loop changes not sticking

I'm trying to modify my exposed filter block to put each of the controls inside fieldsets, and make other modifications to them. However, when I try to utilize a foreach loop to do this, none of my ...
0
votes
3answers
60 views

Drupal_add_js is not working inside hook submit

I have alter and hook submit for webform. I would like to pop a modal if form is successfully submitted. But drupal_add_js seemed to be not working inside the hook submit. function ...