1

Shouldn't be hard, but it is - how do you make a CCK checkbox default checked?!?

I've tried various responses in the PHP Default Value box:

return array(0 => array('#default_value' => 1));
return array(0 => array('default_value' => 1));
return array(0 => array(1));
return array(0 => 1));
return array(1);
return 1;

I'm sure you get the point. None of these work?!

  • Can you paste here the whole form function or whatever you use here? – Alexandru Savin Feb 4 '12 at 7:38
3

I'm a bit confused where you're entering the code above? If I want a checkbox to default to checked then in the UI you can specify this. See screen shot where I've added a field with a label "Shippable".

Default Value

  • Weird, that spot had a blank check box on mine... maybe it has to do with how I'm setting the values. – emc Feb 4 '12 at 23:03
  • @npc It has a a blank value when you're adding it for the first time because the "field label" hasn't been saved yet. Once you go back to edit it after that first save it has the value so it can populate the checkbox label with it – Clive Feb 5 '12 at 0:17
  • More correctly, it's blank if you haven't specified anything for the "On" value or used the field label instead of the "On" value as label. – Malks Feb 5 '12 at 4:00

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.