Î'm just hacking a module for a specialized node type. I haven't come far yet, just started implementing hook_form. As any ordinary node my type has title and body (and some other fields, but not yet). My code so far:
/**
* implementation of hook_node_form().
**/
function mymodule_form($node) {
$type = node_get_types('type',$node);
$form['title'] = array(
'#type' => 'textfield',
'#title' => check_plain($type->title_label),
'#required' => TRUE,
'#default_value' => $node->title,
'#maxlength' => 255,
);
$form['body_filter']['body'] = array(
'#type' => 'textarea',
'#title' => check_plain($type->body_label),
'#default_value' => $node->body,
'#required' => TRUE,
'#resizeable' => TRUE,
'#rows' => 9,
);
$form['body_filter']['filter'] = filter_form($node->format);
return $form;
}
Until now I have always created node types using the generic functions (extended by CCK). All my node types's edit forms do show the "include teaser" checkbox and, having JS enabled, offer the "split" feature to have a separate teaser input box etc. (I do not use Wysiwyg editors here.)
However, my nodetype (which is based on the standard node as well) does NOT behave this way. No checkbox, no dynamic form addons. I tried to find hints (here and elsewhere) but without success.
I am sure that it's a pretty simple issue (as always), isn't it? ;)
Comments
You need something like
You need something like
This would replace your body_filter elements.
Works!
If any forum help were that short and precise, most forums had almost no more pageviews :-)
Thanks a real lot for this!
(Anyhow this is the first (IMO) really important core function I really lacked to find on my own, not even in John van Dyks book.)