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

Is there any way to run hook_form_alter based on a form ’s class instead of it’s ID?

Is there any way to run a hook_form_alter based on a form ’s class instead of it’s ID? I have a class of commerce products and am needing to do form alterations on their add to cart forms. There are ...
0
votes
2answers
25 views

Access submitted form data in custom callback before hook_mail_alter()

I wan't to alter contact form recipient according to what user chose in one of the dropdown fields of my Contact form. I implemented hook_form_FORM_ID_alter() in order to add custom submit callback ...
0
votes
1answer
13 views

Added Classes showed in dpm but don't show up in the output HTML

I want to add some classes into my form (node/add/-- form) so I use hook_form_FORM_ID_alter but I don't know why the classes add to my field in the dpm() output but when I check the html output those ...
0
votes
0answers
16 views

Change text of validation error message of a field in user register form

On this page i want to change the text of the validation error message RIZIV number: the value may be no less than 10000000000. Its from field field_riziv_number How do i manage this?
0
votes
0answers
31 views

hook_form_alter() to make multiple fields as required

I am trying to make field(s) of Entity Form as required. The field(s) that I want to make required works fine when its one field but when I mention that a field(s) can accept unlimited values the ...
0
votes
1answer
17 views

Long text increase maxlength

I have added a textarea and i want to store more that 1024 characters in it. Long text is the field type that i have chosen but an error comes up saying :Keywords cannot be longer than 1024 characters ...
1
vote
1answer
28 views

How to add CSS class to password-strength and password-confirm on /user/register page?

I want to add a class to password-strength and password-confirm on /user/register page? I tried to alter the form but as these are made with js I could not change or add anything to them. How can I ...
0
votes
0answers
24 views

hook_form_FORM_ID_alter: add class to field? Not working as expected

I thought I could add a class to a field in a form using hook_form_FORM_ID_alter. But even after clearing cache multiple times with Drush (drush cc all) it's not working, even though I know the module ...
0
votes
1answer
15 views

Field with '#type' = 'hidden' in hook form alter doesn't show #id in the source and it's not possible to show it with jQuery

I put in my template.php an hook_form_alter function where I assign '#type'= 'hidden' to "field_bergamo". But I want to show it when in the select list "Provincia" of the same form I select the ...
0
votes
0answers
5 views

Adding #ajax to an existing dropdown menu

I'm trying to add the #ajax property to a dropdown menu on a node add form. If I add the following code to a hook_form_alter, the ajax triggers correctly (on blur the ajax circle spins next to the ...
3
votes
2answers
35 views

Render same field twice but with different name/id attribute

I have overriden user-register.tpl.php and in it I would like to render same checkbox twice (So that I can submit if either of them have been checked and they are the same I just need to display them ...
1
vote
1answer
39 views

hook_form_user_register_form_alter() does not customize user registration form

I have implemented a hook_form_user_register_form_alter(). function hook_form_user_register_form_alter($form, $form_state, $form_id) { $form['account']['name']['#description'] = 'This is your login ...
0
votes
0answers
16 views

Form framework doesn't render date type after ajax callback

I have an ajax callback which returns a date type input field. The problem is any other input type other than date is generated, but date type is not rendered at all. The title, and description is ...
0
votes
0answers
12 views

Create an article translation(s) via hook_form_alter?

I would like to submit an article in English but when I press submit button I would like to create its translation(s) as well. Can I do it with hook_form_alter? I have this now: /** * Implements ...
0
votes
0answers
11 views

Apache Solr form alter add custom fields in search form

I wanted to alter the apache solr search form by adding my own custom textfields, dropdowns. I tried using the regular form alter hook but it works only for the Core search i.e custom fields appear ...
0
votes
0answers
29 views

How do I set the #default_value of a select list to the first option?

I'm currently using hook_form_alter and $form['#after_build'] to try and set a term reference select list's default value to the first option in the list. I'm using the Reference Option Limit module ...
1
vote
1answer
93 views

How to retrieve a select box option and set the field's value to it?

I have a a taxonomy term select box (called "product_keyword") in a node that gets its options populated via the Reference Field Option Limit module. There are 3 other taxonomy term reference fields ...
0
votes
1answer
32 views

Prevent form rebuild on image upload

I have content type Gellery with two fields. Image (Multiple) Game Name (Entity Reference) I am setting Game Name in hook_form_alter. Lets say it is set to "Game 001". When image is uploaded, it ...
1
vote
1answer
18 views

Adding custom form to form_alter — help please

I've been trying for awhile to add a custom form to a custom module so as to make it show in drupal profile Edit page. Using the normal $form['submit'] messes up the other forms in the page, so tried ...
0
votes
0answers
14 views

Move scheduler settings to multipage field group

All fields for node creation are in multipage groups. Fields that I don't need like comment settings, menu settings etc. I've set access to false in form_alter or after_build. Only scheduler ...
0
votes
2answers
29 views

Custom edit user page

I'm trying to build an edit form for specific users. For one type of user I want to hide password field for example What I did is to create a module called profilechange. Into profilechange.module ...
0
votes
1answer
18 views

How can I edit a node field in view page?

I want to edit a node field in a view page. Drupal has the modules editablefields and Editable Views to support for editing fields in a view page but it conflicts with some modules. So I want to write ...
0
votes
1answer
40 views

Add #ajax to an existing form

I'm trying to add the #ajax property to the add form of a simple existing content type. I thought hook_form_alter would be the way to go, but the code below doesn't get me the updated results I'm ...
0
votes
2answers
48 views

How do I skip validation for node form element?

I have a content type having 10 fields that are all required. How do I skip validation for some fields? Is there any hook/function that allow me to do this?
1
vote
2answers
48 views

How do I check a form is a node type form?

I am writing a custom module and I want to add some condition in hook_form_alter() to check the form is a node type form. Is there any function to check whether a form is for a node?
0
votes
1answer
33 views

Hook form alter not firing on a custom form that does exist [closed]

I have a hook form alter function that is not recognizing or firing on a form that clearly does exist on the page. And i’ve tested this function against the Drupal built in form with the id of ...
0
votes
0answers
27 views

Call form validation function by clicking link

I want to be able to click a link on my form and have it call the form's validation function (but not actually submit it!). Here's what I've got that's partially working: in form_alter: ...
0
votes
0answers
13 views

Change registration form structure Drupal [duplicate]

I want to change the HTML structure of the drupal registration form. I have no idea where to change it. Any suggestions?
0
votes
4answers
73 views

How do I programmatically create a title for a new node?

My client wants the title field of each new node of their Agenda content type to be constructed automatically from a date field in that same node. I have variously tried setting the #default_value ...
0
votes
1answer
44 views

Getting the node object in hook_form_FORM_ID_alter

Follow up to this question but I don't have enough reputation to ask clarification in a comment. I am porting a contributed module to Drupal 8. The sugested code on the above mentioned CR and post ...
0
votes
0answers
25 views

Adding theme settings via module?

In Drupal 8, what is the recommended way to add new settings to system_theme_settings form? I tried using hook_form_FORM_ID_alter(), but I can't figure out how to save values for theme settings. ...
0
votes
0answers
25 views

One hook_form_alter messing with another

I have 2 hook_form_alter implementations. One in module 1 and the other in module 2. I look for $form_id == 'user_login' in both. When a user is required to have to login because of some functionality ...
1
vote
0answers
28 views

Why is Form '#states' not working?

I've used the Address Field module in my registration form with other fields. I've one select field to display some numbers and one textfield to get some numbers from users. This textfield should be ...
0
votes
0answers
17 views

Form API hook_form_alter not working [duplicate]

I am trying to set a default value using hook_form_alter on an entity form, and the usual thing I do is not working, can anyone see why? Here is the dsm($form) ... My module is called "pinboard" ...
0
votes
0answers
24 views

Updating a theme_table inside a form via AJAX callback

I have a form with a table (not a tableselect) that I use with 2 inputs: one to add some information and a button that (I hope) will delete its corresponding row when clicked. I also have a button in ...
0
votes
1answer
19 views

Form_set_error for array of fields

I got below code in form_validation $form_state['values']['field_address'][LANGUAGE_NONE][0][postal_code]; I've tried below tricks but it didn't make red color in textbox. ...
-1
votes
1answer
51 views

How do I add javascript code to number field?

I have a Number type field in webform for phone number, in chrome it does not allow to enter characters while in mozilla it allows and on submit it shows "enter number" message. now i need to add this ...
0
votes
0answers
16 views

Print success message only if field is altered [duplicate]

I have created a checkbox in user edit using form alter and based checkbox state I want to print the message. For this I used below code function module_form_user_profile_form_alter(&$form, ...
0
votes
1answer
26 views

How to customize the add-to-cart form using hook_form_alter?

How can add-to-cart form be customized using hook_form_alter. Or better yet can layouts like display suite or panels be applied to the add to cart form using hook_form_alter? I have custom line item ...
0
votes
1answer
27 views

How to identify and target a form element?

A similar question has been asked before: How do you identify a form element? I am using the Devel module and dpm($form) outputs the object nicely: But I can't set/change the default value of a ...
1
vote
1answer
45 views

Print message only if checkbox field is alter using form alter

I have created a checkbox in user edit using form alter and based checkbox state I want to print the message. For this I used below code function module_form_user_profile_form_alter(&$form, ...
1
vote
2answers
62 views

Update webform field value using AJAX realtime

I have a webform created using the admin panel and would like to change one of its textfield values on click of a button. I have attempted doing this from hook_form_alter. I have given the wrapper ...
2
votes
1answer
28 views

Alter form field from module

In my user profile, I have some fields I want to alter. For my regular fields I use: mymodule_form_alter(&$form, &$form_state, $form_id) That works, but inside the $form there are some ...
0
votes
1answer
48 views

Hide Fieldset in an Ajax Callback Function

I have this code below: function myid_templates_form($form, &$form_state){ $form = array(); $form['create_template'] = array( '#type' => 'button', '#value' => ...
0
votes
1answer
19 views

How to render form filed from another form in Druapl 7

I am having two different forms, i need to render a from first form filed into second form.When i am add data in that field that need to store into first form value.
1
vote
1answer
39 views

How hook_form_alter() works in Drupal? [closed]

How hook_form_alter() works in Drupal? It will work when the form is just loaded right ? I need to modify the form variables before submission only . Suppose i am modifying some form variables after ...
0
votes
1answer
37 views

Add extra button on webform and Ajaxify

I'm building a form similar to attached image. Customer enters values for all 3 text fields and click 'Get Online quote'. This will perform a database query (using AJAX) and display a value just ...
0
votes
1answer
26 views

Webform: How to prevent rendering of private fields

I'm using Webform. Because I wanted to add custom flag for submitted data, so I used this approach with private fields http://drupal.stackexchange.com/a/137847/24385 Is it possible to render such ...
1
vote
0answers
22 views

Is there a way to get faster dependent dropdowns?

I have a complex node form with a series of dependent dropdowns (pick option a, update choices for option b, pick b, update choices for option c, etc.). It's all working fine with the standard ajax ...
1
vote
0answers
49 views

How to add confirm form with form alter?

I would like to add a confirm form for the edit page of an entity (commerce product in this case), which only appears when an certain form field has a certain value. I did succeed to set up a confirm ...