Hi
I have a node with many CCK fields. I want to hide a field from anonymous user. I found there are roughly two approaches from http://www.lullabot.com/articles/modifying-forms-5-and-6. First, I tried theme_theme() with the code below
function ssaa_theme1(&$existing, $type, $theme, $path) {
return array(
'volunteer_node_form' => array(
'arguments' => array('form' => null),
),
);
}
function ssaa_volunteer_node_form($form) {
$out = '';
if (user_is_anonymous()) {
unset($form['field_active']);
}
$out .= drupal_render($form);
return $out;
}
This simple code worked well as I expected but produced strange result too. Save/Preview buttons are appeared on the top of the form and I couldn't move them to the bottom. At first I suspected drupal_render() function but it didn't do anything about the order. It produced same result when ssaa_volunteer_node_form() function was empty.
So I tried second option which uses hook_form_alter() and succeeded. But I still want to figure out why first approach didn't work properly. I think it's more easy and light way to do what I want to do.
Any ideas?