Установить значение по умолчанию для флажков в Drupal - PullRequest
1 голос
/ 29 декабря 2011

Я пытаюсь установить #default_value в форме D7, но она не работает ... Это мой массив:

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

После редактирования этой формы с этой строкой:

$form['thema_30fdc789-1453-4efa-93d6-123cab52206e']['#default_values']= 
        array('create' => 'Nieuwe fiches', 'update' => 'Update fiches', 'delete' => 'Delete fiches');

Я получил это 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)

Итак, hook_form_alter сделал свою работу. Тем не менее, флажки не перезагружаются при перезагрузке страницы ... Что мне нужно сделать, чтобы убедиться, что они отмечены?

1 Ответ

1 голос
/ 29 декабря 2011

Nevermind. Я нашел это сам. Мне нужно было настроить строку следующим образом:

$form['thema_30fdc789-1453-4efa-93d6-123cab52206e']['#default_value'] = array('create', 'update','delete');
...