Hi,
I faced a problem and I think there is something that need to be fixed in october.form.js.
Version October : v2.2.34
I have a model Pool with :
public $belongsToMany = [
'dealers' => [Dealer::class, 'table' => 'larnet_osm_pools_dealers'],
'users' => [User::class, 'table' => 'larnet_osm_pools_backend_users'],
];
Then, in my fields.yaml :
fields:
dealers:
label: 'larnet.osm::lang.backend.pool.form.dealers'
type: relation
disabled: true
users:
label: 'larnet.osm::lang.backend.pool.form.users'
type: relation
The issue is when I put disabled: true in the definition of the field dealers, it will disable the field users as well.
In modules/backend/widgets/form/assets/js/october.form.js, line 68+ :
/*
* Logic for checkboxlist
*/
FormWidget.prototype.toggleCheckboxlist = function() {
var $field = $('.field-checkboxlist', this.$el),
isDisabled = $field.hasClass('control-disabled');
$('input[type=checkbox]', $field).prop('disabled', isDisabled);
}
I think the problem is because it will find the class ‘control-disabled’ of ‘dealers’ and disable all input, including ‘users’ even if it’s not disabled.
Changed to this :
/*
* Logic for checkboxlist
*/
FormWidget.prototype.toggleCheckboxlist = function() {
var $field = $('.field-checkboxlist', this.$el),
isDisabled = $field.hasClass('control-disabled');
$('.field-checkboxlist.control-disabled input[type=checkbox]').prop('disabled', isDisabled);
//Original below, it will disable all checkbox
//$('input[type=checkbox]', $field).prop('disabled', isDisabled);
}
And now, it will disable only the input under the right container that is disabled, in this case, ‘dealers’