Can I have fixed cropping with images?
How can I specify a default value and hide this checkbox ?
[states] => Array
(
[#type] => checkboxes
[#title] => Status
[#options] => Array
(
[active] => Active users
[inactive] => Inactive users
)
[#description] => Subscriptions matching the selected states will be exported.
[#required] => 1
)
I've tried
$form开发者_Go百科['states']['#default_value'] = 'active';
but it gives me an error.. thanks
Your code as written will produce a syntax error, since you're declaring the 'states' array wrong. This is a PHP syntax thing that doesn't really have anything to do with Drupal's forms API.
Try:
$form['states'] => Array (
'#type' => 'checkboxes',
'#title' => t('Status'),
'#options' => Array (
'active' => 'Active users',
'inactive' => 'Inactive users',
),
'#description' => t('Subscriptions matching the selected states will be exported.'),
'#required' => 1,
'#default_value' => 'active',
);
Unrelated to the syntax issue, a better way to do this would be to reset the entire form element as a '#type' = 'value'. For example $form['states']['#type'] = 'value'; $form['states']['value'] = 'whatever'
精彩评论