I know how to populate the form fields in hook_form_alter but i have no idea how to hide them...

regards Volkan


I found a solution at lullabot


Too lazy to read try to add '#access' = false to your form element

$form['author']['name']['#access'] = FALSE;

Please note that if you restrict the access permissions for a form field, then you are also restricting the active user's ability to submit any value for that field, whether via manual entry or via hook_form_alter() 'fu.

That is, this hook_form_alter() code wouldn't work:

$form['author']['name']['#access'] = FALSE;
$form['author']['name']['#value'] = 'something';

As an alternative, try simply hiding the field (or change to type hidden) if you still want the acting user to modify a form's field in some controlled way:

$form['author']['name']['#prefix'] = '<div style="display:none;">';
$form['author']['name']['#value'] = 'something';
$form['author']['name']['#suffix'] = '</div>';

Ben West