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

learn more… | top users | synonyms

0
votes
0answers
18 views

How to set a Select Multiple Form Field in code

I'm editing the _node_form_alter section of a module that has to interact with GCC (v7.x-1.0-beta2) and trying to set the 'Associate with the following groups' field. I've been able to set a custom ...
0
votes
2answers
38 views

Why can't i get simple form theming to work?

I've got this implementation of hook_theme in a theme : function uncoated_theme($existing, $type, $theme, $path) { return array( 'uncoated_user_register_form' => array( 'render ...
0
votes
1answer
17 views

Form Default Values missing on theming form

Long story short when doing some basic theming on a drupal form the default / previously saved values refuse to display within the form fields (works without theming of course). In the code exerpt ...
0
votes
0answers
18 views

How to insert <button> controls into forms?

I'm looking for a simple solution to insert straight <button> controls into a form. Drupal seems to convert elements with #type => button into <input type="button"> markup. What's the ...
-1
votes
0answers
15 views

Remove fields of form in hook_form_alter() based on conditional date

I have group of fields in a content type form from FIELD COLLECTION module. By default a select box which contains "Confirmed/Not Confirmed" save "Not Confirmed" value when node is created. I have ...
0
votes
1answer
32 views

How to hide certain fields on the User Edit form?

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 ...
1
vote
1answer
24 views

How should I alter forms shown in a block?

I want to alter the login form to display only the @username and @password inputs. Is it mandatory to write another module to overwrite the user module? Can it be done from my PHP block by using ...
0
votes
1answer
27 views

How To Hook To Commerce Checkout Button?

I need to add a custom function to the Confirm Order button on a Commerce Checkout form. I can't figure out how to call it. The button id is "#edit-continue' and its displayed text is 'Confirm Order'. ...
0
votes
1answer
26 views

Run a boolean test function on form submit

Is there a way to run a function when a user submits a form in Drupal that returns a true or false. If it is true, run the submission handler. If false, return an error. Application: I am using ...
-1
votes
0answers
19 views

How to redirect to a specific admin page and alter the form there? [closed]

I custom create users. I want on each user creation to check specific option found on administration side on a form provided by another module. (e.g. it allows user to receive notifications by ...
0
votes
1answer
36 views

Node edit layout based on Role

I want Authenticated users to be able to add content (a custom content type). However, they should not see all the fields. Users with a Role of "manager", should be able add/edit this content type, ...
0
votes
1answer
17 views

Add additional element to exposed view form?

I'm trying to modify an exposed view form by adding some additional markup. My current code looks like this: if ($form_id == 'views_exposed_form') { if ($form_state['view']->name == ...
0
votes
0answers
16 views

Taxonomy field - select multiple height (size)

I'm trying to change taxonomy field height - <select multiple="multiple"> in admin overlay area. I hadn't success, I was trying with form alter like this: function ...
0
votes
1answer
30 views

page “/node/add” that I would like to programmatically limit the links that are displayed based on the users role

I have a page "/node/add" that I would like to programmatically limit the links that are displayed based on the users role. Is using either hook_form_alter or hook_form_ID_alter the way to do this? I ...
1
vote
1answer
44 views

Filter a field (with regex) in a view

I have a view with a field Title that needs to be filtered before being sent: Users fill a tracking number and press Enter This number is actually related to a node id If a user enter "123 123" or ...
0
votes
1answer
54 views

Drupal 7 hook_fom_alter not working for custom fields

I have added custom field for email address in my content type. I want to assigned default email address to this field. Following is my code. function request_order_form_alter(&$form, ...
1
vote
1answer
41 views

Custom url inside the button

I was creating my first project with drupal and now my problem was the request new password since this is a link and i want to make it into buttons so i generate my hook_form_alter but i got a problem ...
0
votes
0answers
13 views

Term Reference Update Event

I Have implemented a term reference field in my custom content type. The widget i am using is hierarchical select. Now when a content type is being created a hierarchical select box is shown, if a ...
3
votes
1answer
71 views

How to target and remove a given fieldset

I am very new to drupal and have been playing around with lots of different modules and core features. I have now come to an issue I have been trying to solve for the pass 48hrs without finding the ...
0
votes
1answer
55 views

user register hook form alter not reaching

I am trying to request more information from users when they register for my site. I put a set-message in and it's not eve appearing nor any changes in the user register form. I cant seem to find ...
0
votes
1answer
53 views

Empty response after a callback in form_alter

I am trying to add a new field in a preexistent form and invoke a callback. The response of the callback is alway an error with an empty response: An AJAX HTTP error occurred. HTTP Result Code: ...
0
votes
1answer
23 views

hook_form_alter building dynamic textfields

In hook_form_alter I am fetching data from the database. Some of the data has several textfields, lets say addresses. People can have several addresses. How can I pass the count of rows to my form, ...
1
vote
2answers
57 views

how to know if a form_alter is being invoked through an ajax request?

I am altering a node add form using hook_id_form_alter and inside that i am doing a drupal_goto, if query parameter is missing a mandatory token value. Now, in the add node form, there is an image ...
0
votes
1answer
31 views

Set default value of field in a field group

I have had no luck trying to set the value of a field in a field group. I can see in the array that the default value has changed but the change does not show up in the viewed form. This is the same ...
0
votes
0answers
25 views

hook_form_alter not being invoked on ajax form call

As I was instructed, hook_form_alter is being invoked again on form when button "add another item" was pressed (on widget with possible multiple fields) and ajax call has been issued. In my case, ...
3
votes
4answers
389 views

Making drupal7 field readonly using hook_form_alter

I am trying to make some of the drupal profile form field as read only on edit mode . I am using the following code in hook_alter ...
1
vote
2answers
29 views

how to refer to data of referenced node

In drupal 6, I have an event node type and an event_attend node type. The event_attend node type has a nodereference to event. In hook_form_alter for the event_attend node type, i added a validation ...
0
votes
1answer
73 views

Modifying Commerce Cart Before Display

We have a Drupal Commerce cart. The pricing can be altered based on discounts that come in from an external database via XML httprequests. It worked -fine- when the XML requests were made when the ...
2
votes
1answer
46 views

Setting field attribute as read only in hook_form_alter?

I'm trying to create a simple custom module to stop the Title of a specific node being edited. function mymodule_form_alter(&$form, &$form_state, $form_id) { if ($form_id == ...
3
votes
3answers
171 views

How can I create a customised add/node form in D7?

How can I create a customised add/node form in D7? I am not talking about a form for gathering information that is not content for the site, like an event registration form. I'm talking about the ...
0
votes
1answer
136 views

Form submit - close overlay

In order to be able to quickly edit Fullcalendar items, I altered the node edit form of the specific content type so the events are saved with AJAX and the page doesn't have to reload. However, I ...
0
votes
1answer
43 views

How to get the values on the other form

I would like to save the form field values by using mymodule_admin(). How can I get the values saved in mymodule_admin() on the other form without using the database? function subscription_admin() { ...
0
votes
1answer
44 views

How can I notify an admin when a user is contacted?

On my Drupal 7 site, I have a user contact form. How can I alter the form so that an admin is notified when the form is submitted?
0
votes
1answer
64 views

Changing Button Text on Content Type form

I created a content type called "video" and I created a module named df_video.module with: function df_video_video_node_form_alter(&$form, &$form_state) { ...
-1
votes
1answer
221 views

Not saving field values to database using custom submit function [closed]

Specifically, my question is: what am I doing wrong such that the data entered into the various fields is not saved to the database when the form is submitted using the custom submit handler, but is ...
3
votes
2answers
49 views

Empty a field when it is disabled

I am using #state values in a hook_form_alter() to disable field_2 if field_1 (a checkbox) is checked. It works and all is good. Now I want to empty field_2 as well. I cannot see a way to do that ...
0
votes
1answer
81 views

Getting an element of a CCK field to use and modify in hook_form after_build

I have a partially working solution for using hook_form after_build on a CCK field. The field has various elements (it's created with a custom module but I don't want to modify that so I've created a ...
2
votes
0answers
103 views

How do I get a list of Drupal 7 active contexts for the current page/form in hook_form_alter?

I have several contexts defined for my site. In hook_form_alter I need to find out which of them are active. I am trying to use context_active_contexts, but that is only showing 2 of the (at least) 3 ...
0
votes
1answer
21 views

search_form_alter NOT BLOCK

I was looking the insertion point to change some stuff in the search form. I manage to change the search block, but I can't find a way to do the same with the form I see in site.com/search/node I was ...
0
votes
1answer
31 views

add arbitrary descriptions div in a node edit or add form

the need seems simple but I don't find anything about this. I'd like to add descriptions (div class="description"), non related to specific cck fields. I though I could use these to compute ...
0
votes
1answer
68 views

Node edit page not showing up using page.tpl.php?

I'm working on a new drupal 7 site right now (I'm new to drupal) and currently have given the ability to users to create nodes. The node creation page (url.com/node/add/) works just fine and uses the ...
0
votes
0answers
51 views

Drupal Commerce: this hook_form_alter snippet won´t work to hide the postal code of the addressfield. Why?

I want to programatically hide the postal code field, of the address module. I´ve unsuccessfully tried this: function mymodulename_form_alter(&$form, &$form_state, $form_id) { if($form_id == ...
0
votes
1answer
198 views

How to alter a field within an unlimited field collection?

I am trying to set the #access attribute to FALSE on a field that is within an unlimited field collection - so it is hidden from users. I am relatively new to Drupal so I'm not sure how to handle ...
0
votes
1answer
63 views

How to change #weight of fields added to user register page by form_alter()?

I have created some fields on my user registration page named like - First Name (machine name - field_first_name), Last name (machine name - field_last_name) etc.. I want to change their #weight ...
0
votes
1answer
102 views

drupal_set_message on node edit page shows twice with theme hook

I want to display a value of a field which the user has no access to in a dsm when the user edits the page. The dsm is showing up after saving the node, and while that's fine (I'd even consider it a ...
1
vote
2answers
83 views

Modifying Drupal core (search module, image module)

I have a couple of modifications I did to the Drupal core: search module: I added a class to the <ul> that contains the "no-results" text. image module: I changed the 'title' attribute to have ...
0
votes
1answer
70 views

Override Search module's textfield CSS ID

this is what I am using to override the Search module's submit button's CSS ID: function hook_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'search_block_form') { ...
2
votes
1answer
68 views

How do I add a checkbox to the performance page and have it repopulate?

I would like to add a checkbox of my own to the performance page in the Drupal administration. I am using hook_form_alter like this: function nci_assay_depot_form_alter(&$form, &$form_state, ...
0
votes
2answers
100 views

Multiple forms and required fields affecting hook_form_FORM_ID_alter()

When creating a new content type, the $form_id is correctly picked up in my module. Let's say in my example, my form is called the 'foo_form'. The below hook_form_FORM_ID_alter function works fine ...
0
votes
1answer
514 views

Trying to add profile2 fields to user/edit page

I am trying to show the profile2 fields in my user edit page, but I can't figure out how for the life of me. I read that they should autmomatically show up but it's not happening.. I have added the ...

1 2 3