[英]Set default value for checkboxes in Drupal
I'm trying to set a #default_value
on my D7 form, but it's not working... This is my array: 我正在尝试在我的D7表单上设置
#default_value
,但是它不起作用...这是我的数组:
'thema_30fdc789-1453-4efa-93d6-123cab52206e' =>
array
'#type' => string 'checkboxes' (length=10)
'#title' => string 'What kind of fiches??' (length=42)
'#options' =>
array
'create' => string 'New fiches' (length=13)
'update' => string 'Updated fiches' (length=13)
'delete' => string 'Deleted fiches' (length=13)
After editing this form with this line: 使用此行编辑此表单后:
$form['thema_30fdc789-1453-4efa-93d6-123cab52206e']['#default_values']=
array('create' => 'Nieuwe fiches', 'update' => 'Update fiches', 'delete' => 'Delete fiches');
I get this var_dump
: 我得到这个
var_dump
:
'thema_30fdc789-1453-4efa-93d6-123cab52206e' =>
array
'#type' => string 'checkboxes' (length=10)
'#title' => string 'What kind of fiches??' (length=42)
'#options' =>
array
'create' => string 'Newfiches' (length=13)
'update' => string 'Updated fiches' (length=13)
'delete' => string 'Deleted fiches' (length=13)
'#default_values' =>
array
'create' => string 'Newfiches' (length=13)
'update' => string 'Updated fiches' (length=13)
'delete' => string 'Deleted fiches' (length=13)
So, the hook_form_alter
did his job. 因此,
hook_form_alter
完成了他的工作。 Nevertheless, the checkboxes aren't checked on when reloading the page... What do I need to do to make sure they are checked on? 但是,重新加载页面时未选中该复选框...我需要做些什么来确保选中它们?
Nevermind. 没关系。 I found it myself.
我自己找到的。 I needed to adjust the string to this:
我需要将字符串调整为此:
$form['thema_30fdc789-1453-4efa-93d6-123cab52206e']['#default_value'] = array('create', 'update','delete');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.