hook_form_alter
Definition
hook_form_alter($form_id, &$form)
developer/hooks/core.php, line 435
Description
Perform alterations before a form is rendered.
One popular use of this hook is to add form elements to the node form. When altering a node form, the node object retrieved at from $form['#node'].
Parameters
$form_id String representing the name of the form itself. Typically this is the name of the function that generated the form.
$form Nested array of form elements that comprise the form.
Return value
None.
Related topics
| Name | Description |
|---|---|
| Hooks | Allow modules to interact with the Drupal core. |
Code
<?php
function hook_form_alter($form_id, &$form) {
if (isset($form['type']) && $form['type']['#value'] .'_node_settings' == $form_id) {
$form['workflow']['upload_'. $form['type']['#value']] = array(
'#type' => 'radios',
'#title' => t('Attachments'),
'#default_value' => variable_get('upload_'. $form['type']['#value'], 1),
'#options' => array(t('Disabled'), t('Enabled')),
);
}
}
?> 