Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow array types to be set #79

Open
lorenzulrich opened this issue Jan 20, 2024 · 2 comments
Open

Allow array types to be set #79

lorenzulrich opened this issue Jan 20, 2024 · 2 comments

Comments

@lorenzulrich
Copy link
Contributor

lorenzulrich commented Jan 20, 2024

Currently it seems that I cannot create a field with type array:

                salutation:
                  type: 'Sitegeist.PaperTiger:Field.RadioButtons'
                  properties:
                    name: 'salutation'
                    label: 'Anrede'
                    isRequired: true
                    options: [label: 'Frau', value: 'Frau'], [label: 'Herr', value: 'Herr']

How a RadioButtons element looks in the node properties:

{
    "isRequired": true,
    "customErrorMessageEnabled": false,
    "name": "salutation",
    "label": "Anrede",
    "options": {
        "0": {
            "label": "Frau",
            "value": "Frau"
        },
        "1": {
            "label": "Herr",
            "value": "Herr"
        }
    }
}

Error message:

Configuration "childNodes.fields.childNodes.fieldset.childNodes.salutation.properties.options" | RuntimeException(Template configuration properties can only hold int|float|string|bool|null. Property "options" has type "array", 1685725310730)

Is this concious limitation or not possible technically?

@lorenzulrich
Copy link
Contributor Author

Update: I fixed the node template above. When I change

            if (!is_scalar($value) && !is_null($value)) {
                $templatePart->addProcessingErrorForPath(
                    new \RuntimeException(sprintf('Template configuration properties can only hold int|float|string|bool|null. Property "%s" has type "%s"', $propertyName, gettype($value)), 1685725310730),
                    ['properties', $propertyName]
                );
                continue;
            }

to

            if (!is_scalar($value) && !is_null($value) && !is_array($value)) {
                $templatePart->addProcessingErrorForPath(
                    new \RuntimeException(sprintf('Template configuration properties can only hold int|float|string|bool|array|null. Property "%s" has type "%s"', $propertyName, gettype($value)), 1685725310730),
                    ['properties', $propertyName]
                );
                continue;
            }

everything seems to work.

@mhsdesign
Copy link
Contributor

Hi Lorenz sorry for the slow response, i dont monitor this repo super actively ;)

Indeed it was a conscious decision as denoted here and also in the release notes:

!!! Now template configuration properties are stricter validated and can only hold non array types like int|float|string|bool|null. (Using nested arrays might come in handy for new features later like for setting Neos 9 reference properties.) Previously it was also possible to set a property to a list like propertyName = ['foo', 'bar'] instead of using EEL: propertyName = "${['foo', 'bar']}".

Restricting this allows other features in the future as we can leverage this special syntax for anything ;)
It should be feasible to always use for more complex things like arrays and also objects eel and not native yaml.

I hope that explains this and youre fine with the decision?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants