我可以使用图像修复裁剪吗?

时间:2010-09-02 19:11:42

标签: drupal drupal-6

如何指定默认值并隐藏此复选框?

[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
        )

我试过

$form['states']['#default_value'] = 'active';

但它给了我一个错误.. 感谢

1 个答案:

答案 0 :(得分:0)

您编写的代码会产生语法错误,因为您声明'states'数组错误。这是一个PHP语法,与Drupal的表单API没有任何关系。

尝试:

$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',
);

与语法问题无关,更好的方法是将整个表单元素重置为'#type'='value'。例如$form['states']['#type'] = 'value'; $form['states']['value'] = 'whatever'