For now, OC can only disable whole checkboxlist, but it will be great, if we can set “disabled” for each option separatelly.
for example, in method getRecipientsOptions
i will sent something like
function getRecipientsOptions() {
return [
'item1' => [
'This is main label',
'This is description',
'disabled' => true,
'readonly' => true
],
'item2' => [
'This is main label',
'This is description'
]
];
current behaviour sets “disabled” to all checkboxes, when field option disabled is set.
any other options is not reflected, only first two from options array.
with small change in october.form.js
at line 69 (wink… nice line), we can disable this, for fields, where we tried to set “disabled”…
$('input[type=checkbox]:not(:disabled)', $field).prop('disabled', isDisabled);
and for correct “check all” and “uncheck all”
checkAllCheckboxlist($field, flag) {
$('input[type=checkbox]:not(:disabled)', $field)
.prop('checked', flag)
.first()
.trigger('change');
}
of course, we need to change partial _field_checkboxlist.php
to reflect new options…
first of all, setting correct “option based” values
add this lines after line 91
$disabled = $readonly = false;
if (array_key_exists('disabled',$option)) $disabled = $option['disabled'] ? 'disabled="disabled"' : '';
if (array_key_exists('readonly',$option)) $readonly = $option['readonly'] ? 'onclick="return false"' : '';
this will fill out $disabled and $readonly for our specific option, when is processed…
and next somewhere in input field
we need to print out new variables
...
type="checkbox"
id="<?= $checkboxId ?>"
name="<?= $field->getName() ?>[]"
value="<?= e($value) ?>"
<?= $disabled ?>
<?= $readonly ?>
...
this changes will results into this kind of checkboxlist
This is probably most requested funcionality…