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

learn more… | top users | synonyms

0
votes
2answers
20 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
33 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
0answers
49 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
13 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
22 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
21 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
22 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
25 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
28 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
8 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 ...
0
votes
0answers
25 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
26 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
21 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
25 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
27 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
50 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
0answers
14 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
11 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
21 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
2answers
60 views

get nid of created node in custom submit and Page redirect after save

I am using Drupal 7. I have created a content type called person. And I have customize my node person adding form with custom submit button . But uses default Drupal node save function. I just uses ...
0
votes
1answer
18 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
91 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
32 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
23 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
20 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
58 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
84 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
102 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
46 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
48 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
33 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
65 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
87 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
71 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
30 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
44 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
36 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
53 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
46 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
96 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
26 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.
0
votes
1answer
15 views

How can I get the english node title printed on the translated nodes edit page.

Something along the lines of this function THEME_AMENDS_form_alter(&$form, &$form_state, $form_id) { global $language; $lang = $language->language; $translations = ...
0
votes
2answers
47 views

why don't set the placeholder attribute for contact field?

this is my hook_form_alter function for set the placeholder attribute and other stuff: function mysubtheme_form_alter(&$form, &$form_state, $form_id) { switch ($form_id) { case ...
0
votes
0answers
35 views

How to prefill multiple value autocomplete field when creating a node page using form alter

I am working on a todo content type that has "Assigned to" autocomplete field which is a multiple value field. I am able to assign one default user based on the third argument passed via URL ...
1
vote
0answers
27 views

Format inline drupal form elements

I got this: As you see I already aligned label and input field inline with CSS, because they are both inside same container, but the button is outside. I was wondering if I could somehow move the ...
0
votes
1answer
42 views

Views VBO: Set custom action with custom attributes selected in form

I have a view of persons. I like to add the persons to an event. I also like to set the status of the resulting relation to one of the values "optional" or "required". Therefore I use VBO on a list ...
0
votes
1answer
67 views

Preventing webform saving in database

Is there a way to prevent a webform submission to be saved in the database? I have added a custom submit handler to my webform but I don't want to save in the DB but send it to an external ...
0
votes
1answer
122 views

Maximum upload size for file is not working

I have set file filed with 25MB Maximum upload size. But when i upload more then 25mb file it is uploading. How to stop this.Can we create any custom module for file size.
0
votes
2answers
30 views

How to find out which form I want to alter

I am adding a functionality to drupal commerce kickstart, which involves product display modification. There should be a lot of forms but I don't which one to alter and add my new object to the ...
0
votes
0answers
56 views

Creating horizontal tabs in edit-form programmatically and moving fields to them

I am building a module which should create horizontal tabs in node-edit-forms and move existing fields into them. Creating the tabs works fine: function add_adminviews2forms_form_alter(&$form, ...