hook_form_alter() - hands on

Event Date/Time

Fri, 3 Dec 2010 - 11:00 am - 1:00 pm

Stanford Law School, rm 283

Notes from the MoC

function mymodule_form_page_node_form_alter has to be in the module - not in template.php

Module forminspect can be used to get form info (press view releases to download this module)

Two main hooks are
and hook_form_FORM_ID_alter

[unset Preview Button]

function mymodule_form_alter(&$form, &$form_state, $form_id){

if ( $form_id == 'page_node_form' ) {
unset ( $form['buttons']['preview'] );

function mymodule_form_page_node_form_alter(&$form, &$form_state){
unset ( $form['buttons']['preview'] );

Other modules can overwrite form ids (for example Profile module overwrites User registration form), so module Util can be used to set module's order

Last modified Fri, 3 Dec, 2010 at 13:01