I need to move the 'Sticky' option to somewhere more visible on a form.
To do this, I'm using hook_form_alter as shown below.
My new field displays on screen, but never has the correct value (if I leave in the original sticky field, that *does* show values correctly).
So, what should I set the default value to in order to have the correct value (checked or unchecked) shown?
Thanks in advance.
Pete.
-----
function mymodule_form_alter(&$form, $form_state, $form_id) {
if (substr($form_id, -10)=='_node_form') {
unset($form['options']['sticky']); // remove the existing sticky field
// Create a new sticky field
$form['sticky']= Array
(
'#type' => 'checkbox',
'#title' => 'Sticky at top of lists - new field',
'#default_value' => $node->sticky,
);
}
Comments
$form['#node']
$node is not passed into hook_form_alter(), nor is it a global. However, it is available in
$form['#node'].Just the clue I needed
Thanks!
'#default_value' => $form['#node']->sticky,
is the line I needed, solved with the help of your clue.
Regards,
Pete.