Questions tagged [hook-form-alter]

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

hook_form_alter() is the hook implemented by modules to alter the forms implemented by other modules. It allows us to easily alter a form by adding classes for theming, adding extra submission handlers, etc.

60 questions
6
votes
3 answers

How to hide certain fields on the User Edit form in Drupal?

So I have three types of users - admin, LA admin and users. I am trying to set it up so that admins and LA admins cannot edit the username, password and timezone for users. I am talking about the default user edit form for admins and the form ID is…
raeq
  • 971
  • 4
  • 15
  • 36
6
votes
2 answers

drupal alter node edit form

How can I add a custom configuration area to a node edit form just beneath the Authoring Information & Publishing Options section?
sisko
  • 9,604
  • 20
  • 67
  • 139
4
votes
1 answer

After submit action in form_alter

i need to insert data in my tables after user creation. I think to use hook_form_alter() for $form_id == "user_register" but I don't know how to say "after you created user, do this." How can I do it in hook_form_alter()?
Cris
  • 12,124
  • 27
  • 92
  • 159
4
votes
1 answer

set webform component value using hook_form_alter in drupal

I have used form_alter function to change the value of a component but it does not change and default values is stored in the db. when i print the $form the updated values is displaying but not saved in db.
Pramod Kumar Sharma
  • 7,851
  • 5
  • 28
  • 53
3
votes
2 answers

Why can't I move a field into a fieldset in a Drupal form - fails to pick up current value

I have a node form in Drupal 7, in order to simplify it for the user I want to break it up into sections using the vertical tabs feature. Using hook_form_FORMID_alter() I can move the fields without difficulty. When the node is saved, it writes the…
3
votes
1 answer

Drupal 7: How to alter image field widget "alt" or title" label

I am trying to change the "alt" and title" labels in the Image Widget on the node add form. I have tried both of these hooks: hook_field_widget_form_alter hook_form_alter I was unable to find where I needed to go to successfully alter the label.…
Jnicola
  • 96
  • 2
  • 11
2
votes
1 answer

Drupal hook_form_alter: how to target only node/edit and NOT node/add. Aso, why #disabled doesn´t work?

I want to disable a cck field inside a specific form in Drupal 6. I´ve created a new module full of alterations, using hook_form_alter. The form id is articulo_node_form. The field in question is text, I´ve checked and it can be disabeled. I´ve…
Rosamunda
  • 14,620
  • 10
  • 40
  • 70
2
votes
5 answers

Drupal 7 load profile2 programmatically

I have two profile2 profiles defined - main and customer_profile. Also, I have a node type called Customer. When creating a new Customer node, I would like to load the custom_profile form. The idea is to create a node and a profile simultaneously. I…
sisko
  • 9,604
  • 20
  • 67
  • 139
2
votes
2 answers

Drupal 7 Edit User Page Override

I need to override the 'user/%user/edit' page for a specific user role, say 'foo_role'. I have successfully created the new user registration form that explicitly selects the fields to be used in creating a new foo_role user however, because there…
luckyape
  • 722
  • 8
  • 22
2
votes
1 answer

Drupal 7 - Attempting to add custom validation to all node edit forms

I want to add custom validation to all node edit forms. Specifically, will make any image field alt and title attributes required. But I haven't even gotten to that piece yet. So far, I have the following code, but for some reason my validation…
Chris L
  • 41
  • 1
  • 4
2
votes
1 answer

Drupal 7 Views Expose Filter Price Range as Checkboxes

I am using Drupal 7 to build a product reviews site. The product reviews search page is built with Views 3 and Better Exposed Filters. I need an exposed filter for a price field that consists of price ranges as checkboxes. I have set up a grouped…
1
vote
1 answer

Customize form to make it multipaged

A module I am using provides a single paged configuration form. But for my additional configuration purposes, I am attempting to make it multipaged with one additional page for collecting extra configuration data. I am implementing hook_form_alter…
sisko
  • 9,604
  • 20
  • 67
  • 139
1
vote
1 answer

Populate Webform hidden field with title of referring node

Drupal 7 I'm having a similar problem to one that's been presented previously but so far I've not been able to make any of the suggestions work. I have 'Product' pages of content type 'Software Products'. I want to place a link on the product pages…
lshore
  • 11
  • 1
  • 3
1
vote
2 answers

How to make file attachment required for a content type in Drupal

I want to make the file attachment option as a required field for a specific content type, user could not submit the node form without an attachment. the way i am doing this is not working, pls guide me if i am doing it wrong way. function…
Punit
  • 1,110
  • 1
  • 8
  • 14
1
vote
2 answers

how to set default option of node reference cck field through form alter

I accept the arg from the url and according to the arg value I need to set the default option value, here is the code: function ims_form_alter(&$form, $form_state, $form_id) { switch ($form_id) { case 'media_content_node_form': …
Punit
  • 1,110
  • 1
  • 8
  • 14
1
2 3 4