Skip to content

Workflow attributes - Unable to set null as a default value for a boolean #1130

@barillet

Description

@barillet

Summary
I want to create create a boolean workflow attribute with a null default value, but it is converted to false automatically

Steps to reproduce
Add something like that in the appropriate workflow :

workflows:
    <workflow_name>:
        attributes:
            boolean_att:
                property_path: <path>
                type: boolean
                default: null

Actual Result
In the database, the column boolean_att is set to false.

Expected Result
The boolean_att have to be set to null by default to have a rendered unchecked radio buttons.

Details about your environment

  • OroPlatform version: 6.1.6
  • PHP version: 8.4.11
  • Database (MySQL, PostgreSQL) version
    Additional information
    I have managed to set it to a nullable attributes by updating the condition in WorkflowConfiguration.php#L271-L273 to the following :
if (!empty($value['type']) && in_array($value['type'], $castedTypes, true) && (!array_key_exists('default', $value) || !is_null($value['default']))) {
    settype($value['default'], $value['type']);
}

I've done a patch for it in our project by I just want to ask if this is the suitable approach. If yes, maybe this should help for the next release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions