5

I'm trying to create a very slimmed down node edit page for a content type. One of the things I'm doing is hiding the additional_settings section with #access = false.

This is what I'm using:

$form['additional_settings']['#access'] = FALSE;
$form['options']['status']['#default_value'] = TRUE;

With #access = false, when I save the node after editing, it set to unpublished.

I've tried using $form_state['values']['status'] = TRUE; in a form submission handler, but that doesn't help.

10

You could just convert the element to a value type, that way it will be hidden from the form display but will be passed through to the submit handler as normal:

$form['options']['status'] = array(
  '#type' => 'value',
  '#value' => 1
);

You can do the same thing for the rest of the elements in that fieldset, then set the fieldset itself to a container type and remove the title:

$form['options']['#type'] = 'container';
$form['options']['#title'] = '';
  • 1
    This is basically what I ended up doing. Setting options->status->type to 'value' made my form work properly even with my original method of hiding everything. – Joren Apr 18 '12 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.