atk4 / ui

Robust and easy to use PHP Framework for Web Apps
https://atk4-ui.readthedocs.io
MIT License
444 stars 106 forks source link

ScopeBuilder does not work with boolean type #1855

Open mvorisek opened 2 years ago

mvorisek commented 2 years ago

When I open demos/form-control/scope-builder.php demo and change the model to Atk4\Ui\Demos\File which has boolean field and then:

click/add that boolean field:

image

and click Save (on the ScopeBuilder demo) I get:

image

mkrecek234 commented 2 years ago

@mvorisek There is another issue with ScopeBuilder and boolean type - please use the following conditioned model in scopebuilder demo and you'll see it:

$model = new File($app->db, ['caption' => 'Demo Stat']);
$model->addCondition($model->fieldName()->is_folder, false);

As type strictness has increased in atk4/data, the getOption function passing a $value = false will render an exception and not allow boolean type in this function: https://github.com/atk4/ui/blob/28fc62448334a72943b23527c3889e8a4dda0d79/src/Form/Control/ScopeBuilder.php#L689

If you don't require $value to be string, it works as intended.

mkrecek234 commented 2 years ago

P.S. Only if is_folder = false is converted to "0" in string, the radio buttons of the rule are properly pre-selected to "No". So a proper type conversion from boolean to string for $value in this case is required to make it work properly.

mvorisek commented 1 year ago

Since https://github.com/atk4/ui/pull/1915 upgrade there is another known issue - enum/checkbox is broken, boolean/radio has no support by upstream https://github.com/nightswinger/vue-fomantic-ui/issues/16 lib (see _unit-test/scope-builder.php demo for reproduce).