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

Issue #4036: Allow for an empty option in select fields via schema pr… #4037

Open
wants to merge 4 commits into
base: 2.x
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modules/json_form_widget/src/StringHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public function handleStringElement($definition, $data, $object_schema = FALSE)
// Add options if element type is select.
if ($element['#type'] === 'select') {
$element['#options'] = $this->getSelectOptions($property);
if ($property->empty_value) {
$element['#empty_value'] = '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we're going a different direction anyway, but not sure where $property->empty_value is supposed to be getting set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I supposed it to be set in the schema .json file, just like "type", "format", etc. But yes now we are going a different and better way.

}
}

// Add extra validate if element type is email.
Expand Down