Default values in hook_form_alter

Joined: 11/28/2008

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 (if you have a better way, let me know!)

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 listsaaaxxx',
'#default_value' => $node->sticky,

);
}

Peter Connolly
Technical Director
KP Direction LLC
http://www.kpdirection.com
http://www.kids-faith.com

Joined: 11/28/2008
Found the answer...

$node is not available at this point, so I needed to change the default value to

'#default_value'=>$form['#node']->sticky,

And everything now works...

Peter Connolly
Technical Director
KP Direction LLC
http://www.kpdirection.com
http://www.kids-faith.com