Вы можете использовать javascript, чтобы сделать то же самое:
//selection box
echo $this->Form->control('assigned_to',['options' => $usersTo, 'empty' => true, 'value' => $selectedUser, 'id' => 'assigned_to']);
//submit buttons
<?= $this->Form->submit(__('Direct Assign'), ['name' => 'btn', 'class' => 'button', 'id' => 'direct_assign']) ?>
//this must be disabled or hidden if selection box is empty
<?= $this->Form->submit(__('Save'), ['name' => 'btn', 'class' => 'button']) ?>
$(document).ready(function(){
// check the value of assign selection box when document is ready
let assignedValue = $("#assigned_to").val(); // get the value of assign selection box
if(assignedValue == '') {
$("#direct_assign").attr('disabled', true) // to disable direct assign button
}
})
Надеюсь, это поможет!