Skip to content

Support null values in enumΒ #40

@lkmorlan

Description

@lkmorlan

A nullable field may have null as a value in its enum property. This will result in an error like this:

TypeError: SchemaForms\Drupal\FormGeneratorDrupal::SchemaForms\Drupal{closure}(): Argument #2 ($opt) must be of type string, null given in SchemaForms\Drupal\FormGeneratorDrupal->SchemaForms\Drupal{closure}() (line 497 of /var/www/html/vendor/e0ipso/schema-forms/src/Drupal/FormGeneratorDrupal.php).

The error is triggered by the string type declaration on $opt in the anonymous function inside FormGeneratorDrupal::transformRadios() or ::transformCheckboxes().

I an imagine a similar thing happening if the values are integers.

There needs to be code to handle the case where $opt is not a string.

This problem leads to: https://www.drupal.org/project/sdc_display/issues/3478346

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions