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
16 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
12 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
11 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
45 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
42 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
20 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
15 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
34 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
34 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
22 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
36 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 ...
0
votes
1answer
90 views

URL variable not respected when ajax call happens in user registration form

There are some fields (some required, some not) I need to (conditionally) hide in the user creation form: function hook_form_alter(&$form, &$form_state, $form_id){ switch($form_id) { ...
0
votes
0answers
19 views

Programmatically change input filter of term description on taxonomy_form_term

I couldn't find anywhere on the admin UI where I can change the input filter for term's description field. I have tried using hook_form_alter, but wasn't successful. function ...
0
votes
1answer
29 views

How can I add a field in Entityform / hook_form_alter

I'm trying to add a field to the form in hook_form_alter. What's the proper way of adding fields in this hook in case of entityform? I tried to add it this way: $form['leadname'] = array( ...
0
votes
2answers
24 views

Altering button title it becomes inactive

The override function I use in my bootstrap sub-theme template.php: function subtheme_form_titles_node_form_alter(&$form, &$form_state) { $form['actions']['submit'] = array( '#type' ...
0
votes
2answers
24 views

How to compare new node title with already entered nodes in database

I am using node gallery module.While creating an album, when the user enters duplicate name then error message is displayed as This form requires that the fields Album name, Author are a unique ...
0
votes
1answer
27 views

Alter form button title

I use this to alter field labels: function ninesixty_form_user_login_alter(&$form, &$form_state) { $form['name']['#title'] = t('Name'); } But how do I change the title of the button? ...
0
votes
0answers
30 views

How to set the body field as required?

I want to create a forum module. Im using Drupal 6.0 and I want to set body field as required field programmatically. $form['body']['#required'] = TRUE; $form['body'][LANGUAGE_NONE][0]['#required'] ...
1
vote
0answers
11 views

Change workbench_moderation_state from select to radio

I have workbench installed, and want to change the moderation status dropdown in the add node form to a radio. But I don't get it. I have a custom module with a hook_form_alter hook which prints the ...
1
vote
1answer
56 views

Alter Fieldable Panels Pane form

Im using Panopoly, and have created a new Fieldable Panels Pane (FPP) bundle for a specific content type. I notice that all preset Panopoly FPP's have a check box labelled 'Make title a link' inside ...
0
votes
0answers
30 views

Alter webform field before it is rendered

I am VERY new to Drupal (Drupal 7). I am stuck at webform alteration step. So, I have created a content type - News. The News content type has a node reference field for referencing a webform. ...
0
votes
1answer
28 views

Webform Module and Elements Module

I have a hook that i wrote to include the elements fields (i.e, telfield) in a webform. The field doesnt take on the same css as the rest of the fields which means I probably need to add a style to ...
0
votes
1answer
27 views

Add an input[type=“file”] label

i need to style the input[type="file"], the only way to really style them is to add a <label> which has the same for value as the input's id. Drupal does not provide a correct label in single ...
0
votes
1answer
42 views

Drupal 7 add ajax listener directly to node form

I'm trying to register an ajax listener to a checkbox on one of my standard node forms. I want to display certain regions of the form only in case, the field is checked. I can get the drupal ajax ...
1
vote
1answer
41 views

vbo: how to set default values for “modify entity values” form

I have a view with nodes and a views bulk operations field. With this vbo field I like to "modify entitity values" of the selected node. Is it possible: to automatically check the checkbox for a ...
0
votes
1answer
55 views

hook_form_alter checking $user->uid == $node->uid

I need to check if the node uid and the logged-in user's uid are identical when the user is in the node edit form, and then add a class to the form if that condition is true.* The relevant code in my ...
0
votes
1answer
28 views

How to alter a form of content-type to prepopulate FieldCollection of EntityReference fields?

I have three content types : Classroom (some fields) Student (some fields and one EntityReference to Classroom) KMDone (some fields and a FieldCollection) KMDone is a content type which contains : ...
0
votes
0answers
14 views

Move email form to different page and confirm password

Im trying to move the change email form to a separate page just like the chgpwd module does with passwords. However the form doesn't actually seem to do anything when submitted. I also want to make ...
0
votes
0answers
25 views

hook_form_alter and unlimited field values

I need to alter the output for fields when the user clicks the 'add another' button for unlimited values. Basically I want to add an incremental counter into a markup field contained within a field ...
0
votes
1answer
19 views

Saving form data of forms modified with form_alter hook

I understand how to add stuff like checkboxes and fieldsets to existing forms (e.g. the form displayed on the node edit page) using _form_alter. But what I don't understand is how to collect the input ...
0
votes
1answer
139 views

How to programmatically enable/disable Quantity text widget on cart/checkout page?

There are the following things which I've investigated so far: Version of Commerce Cart: 7.x-1.9 Shopping cart form is controlled by commerce_cart_form view. Checkout page is controlled by ...
0
votes
1answer
39 views

hook_form_alter to create table field

I created a form which takes user input for fields: title, link, date and description, however I have another field which is guid and it cannot be user created. This field needs to be created with ...
0
votes
1answer
25 views

How to make blocks contextually aware of current webform page

I have a multipage Webform that lives at a single URL and I would like to place certain blocks depending on which page the Webform is on. None of the webform hooks give access to page number, and the ...
0
votes
1answer
24 views

an entity_metadata_wrapper for a form_content in form alter hook?

There a few days ago, someone in this website advised me to use the function entity_metadata_wrapper. Thanks that, I can get and set fields of entity without use heavy code. Now, I would like find ...
0
votes
3answers
59 views

Alter the form elements on profile page

I have a privacy profile & i want to disable text "No fields have been associated with this profile type. Go to the Profile types page to add some fields" in my form also i want to override text ...
0
votes
1answer
184 views

Node add form alter & submit custom field

I have a content type "event" with a field called "field_pricelist". It's a dropdown with no values, I add the values when I alter the form. The values come from a custom table (install / schema) in ...
0
votes
2answers
109 views

What hook gets called at the formation of a form? (hook_form_alter called for adjusting a form)

what hook gets called at the formation of a form. I'm trying to add some additional mime types to form with id file_entity_add_upload but my hook_form_alter is getting called after these are ...
0
votes
1answer
62 views

Prepopulating county/state field (ajax driven field)

Before I describe my problem, just going to mention that I tried Commerce Addressbook and Commerce Extra (address populate) modules but the first one is not suitable in general for my project (because ...
2
votes
1answer
50 views

Update url query upon form submission

I am trying to append a variable on the URL through a custom submit function. Is that possible? My issue is that I am coming to the node/%/delete from different pages. I want to modify the delete ...
0
votes
2answers
42 views

disable the preview and delete buttons on node edit form

I want to disable the preview and delete buttons on node edit form.I have used the following code.But it is not working. where am i wrong with this? function mymodule_form_alter(&$form, ...
0
votes
2answers
81 views

Prefix html before radiobutton (input field)

I'm looking to insert some extra html before an input radio button. This is my html now: <div id="edit-field-geslacht-und" class="form-radios"> <div class="form-item form-type-radio ...
0
votes
1answer
92 views

How to trigger hook_form_alter() on my custom $form?

I have written a custom module which builds a custom user_profile_form(): mymodule_user_profile_form($form, $form_state, $user) { module_load_include('inc', 'user', 'user.pages'); $form = ...
0
votes
2answers
84 views

dependent dropdowns via #ajax for unlimited option

I have a commerce Product content type, which has a field collection field attached to it field_mycollection, which has 4 different fields field1, field2, field3 and field4 dependent on each other. ...
0
votes
1answer
35 views

How to control path alias in custom node form #validate function?

To change form values in code, I understand that the right way is to add a validate function with hook_form_alter, to append the function's name to the #validate array then use form_set_value. When I ...
0
votes
2answers
49 views

How to alter node form of content-type

How to hook my node form function mymodule_form_alter(&$form, $form_state, $form_id) { if ($form_id == 'node_form') { #Do Something } } I tried above but No result function ...
0
votes
1answer
45 views

How to form_alter fields attached to an unlimited field collection?

Here are 2 unsuccessful experiments I've done: <?php /** * My first attempt with implementing hook_form_alter. */ function MYMODULE_form_alter(&$form, &$form_state, $form_id) { switch ...
-2
votes
3answers
91 views

In form alter change the allowed value list programatically of select box defined using admin content type

I have added a select list field using admin ui in a content type and I want to alter allowed value list and fill dynamically in form alter in drupal 7
1
vote
0answers
59 views

Does AJAX callback functions work differently for BEF views?

I am breaking my head since last two days to implement dependent drop down list. I have followed so many examples in the internet, SE and examples project but for some reason the simple thing isn't ...
1
vote
3answers
98 views

Redirect “edit” tab on single node view

I created custom node edit pages and I want the edit tab to redirect from node/2545/edit to topic/2545/edit or node/2549/edit to arts/2545/edit depending on the content type This is not an ...
0
votes
2answers
30 views

How to hook contact form of drupal 7 for custom styling?

how can I alter my contact form for adding custom classes I am using contact form of Drupal 7 core module.