node_example_form
- Versions
- 4.6 – 7
node_example_form(&$node)
Implementation of hook_form().
Now it's time to describe the form for collecting the information specific to this node type. This hook requires us to return some HTML that will be later placed inside the form.
Code
developer/examples/node_example.module, line 130
<?php
function node_example_form(&$node) {
$output = '';
// In order to be able to attach taxonomy terms to this node, we need
// to display the appropriate form elements.
if (function_exists('taxonomy_node_form')) {
$output .= implode('', taxonomy_node_form('node_example', $node));
}
// Now we define the form elements specific to our node type.
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 20);
$output .= filter_form('format', $node->format);
$output .= form_textfield(t('Color'), 'color', $node->color, 60, 128);
$output .= form_textfield(t('Quantity'), 'quantity', $node->quantity, 10, 10);
return $output;
}
?>Login or register to post comments 