Return to Snippet

Revision: 24289
at February 25, 2010 09:10 by sennesaelium


Initial Code
RENDER ONLY 1 FIELD
<?php print drupal_render($form['group_company']['field_street']['0']['value']); ?>
RENDER A GROUP OF FIELDS
You don't need to render fields in group one by one, just enter this code to render all fields in a group:
<?php print drupal_render($form['group_company']); ?>
RENDER A SELECT LIST
Almost same like render a TEXTFIELD, but avoid ['0']['value'] at the end
<?php print drupal_render($form['group_company']['field_region']); ?>
REMOVE AN INPUT FIELD
You may want to disable an input form, usually you need to remove TITLE as shown below:
<?php unset($form['title']); ?>
HIDE AN INPUT FIELD (HIDE vs REMOVE!)
You may still want to enable an input form but need to prevent it:
<?php $form['title']['#access'] = FALSE; ?>
SHOW ALL VARIABLES OF FORM
You may want to know what variables available for you:
<?php print_r($form); ?>
REORDER
Use ['#weight'] to reorder
$form['buttons']['#weight'] = -50; // buttons at the top
PRINT BUTTONS
<?php print drupal_render($form['buttons']); ?>
RENAMING BUTTON
What is "Submit"? You may need to write it as "Save now!", don't you?
$form['buttons']['submit']['#value'] = 'Save to Database';
HIDE GROUP FIELD-SET
$form['group_general']['#access'] = FALSE;
HIDE BUTTON
$form['buttons']['submit']['#access']= FALSE;

Initial URL

                                

Initial Description

                                

Initial Title
Drupal Form manipulation

Initial Tags
drupal

Initial Language
PHP