Is there a way to have a piklist checkbox field with only one choice that can be true or false based on whether it is checked?
I tried the following, but send_email isn’t given a value unless it’s checked, and I’d like to have it set the value to 0 when it is not checked.
piklist('field', array(
'type' => 'checkbox',
'field' => 'send_email',
'label' => 'Send Email?',
'value' => '1',
'attributes' => array(
'class' => 'text'
),
'columns' => 6,
'choices' => array(
'1' => 'Enable'
)
)
)
In the past, I’ve used the workaround of having radio buttons, but I’d really like to just have an enable checkbox.
My workaround:
piklist('field', array(
'type' => 'radio',
'field' => 'send_email',
'label' => 'Send Email?',
'value' => 1,
'list' => true,
'columns' => 6,
'choices' => array(
1 => 'Enable',
0 => 'Disable'
)
)
)