mercredi 22 mars 2017

Simple form custom wrapper: disabled checkboxes

Simple form documentation about collection_check_boxes:

f.collection_check_boxes(
  :options, 
  [[true, 'Yes'], [false, 'No']], 
  :first, :last,
  checked: checked_values,
  disabled: disabled_values)

They recommend to use disabled: disabled_values as passed attribute (disabled => the value or values that should be disabled. Accepts a single item or an array of items.) and it works ok with default wrapper.

But when I use custom wrapper disabled attribute is not considered:

form.collection_check_boxes(:available_languages,
  select_available_locales,
  :last, :first,
  checked: form.object.available_languages,
  collection_wrapper_tag: 'div',
  collection_wrapper_class: 'available_languages col-sm-3',
  item_wrapper_tag: 'div',
  item_wrapper_class: 'language-item',
  disabled: 'de')

Is there a way to use disabled with custom wrappers?




Aucun commentaire:

Enregistrer un commentaire