Commit da9c2297 authored by zhangtaihao's avatar zhangtaihao Committed by fago
Browse files

Issue #1676206 by zhangtaihao: Fixed Required field with options widget is not...

Issue #1676206 by zhangtaihao: Fixed Required field with options widget is not validated for empty value '_none'.
parent a666cce9
......@@ -1677,11 +1677,13 @@ function field_collection_field_widget_embed_validate($element, &$form_state, $c
foreach ($element['#field_collection_required_elements'] as &$elements) {
// Copied from _form_validate().
// #1676206: Modified to support options widget.
if (isset($elements['#needs_validation'])) {
$is_empty_multiple = (!count($elements['#value']));
$is_empty_string = (is_string($elements['#value']) && drupal_strlen(trim($elements['#value'])) == 0);
$is_empty_value = ($elements['#value'] === 0);
if ($is_empty_multiple || $is_empty_string || $is_empty_value) {
$is_empty_option = (isset($elements['#options']['_none']) && $elements['#value'] == '_none');
if ($is_empty_multiple || $is_empty_string || $is_empty_value || $is_empty_option) {
if (isset($elements['#title'])) {
form_error($elements, t('!name field is required.', array('!name' => $elements['#title'])));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment