diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ChoiceConstraint.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ChoiceConstraint.php index d86503c..f8348b2 100644 --- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ChoiceConstraint.php +++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ChoiceConstraint.php @@ -30,7 +30,7 @@ class ChoiceConstraint extends Choice { public $maxMessage = 'You must select at most %limit choice.|You must select at most %limit choices.'; /** - * Overrides Range::validatedBy(). + * {@inheritdoc} */ public function validatedBy() { return '\Symfony\Component\Validator\Constraints\ChoiceValidator'; diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/LengthConstraint.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/LengthConstraint.php index 61004ef..f9bbfa9 100644 --- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/LengthConstraint.php +++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/LengthConstraint.php @@ -31,7 +31,7 @@ class LengthConstraint extends Length { public $exactMessage = 'This value should have exactly %limit character.|This value should have exactly %limit characters.'; /** - * @inheritdoc + * Overrides Range::validatedBy(). */ public function validatedBy() { return '\Symfony\Component\Validator\Constraints\LengthValidator'; diff --git a/core/modules/options/lib/Drupal/options/Plugin/field/field_type/ListBooleanItem.php b/core/modules/options/lib/Drupal/options/Plugin/field/field_type/ListBooleanItem.php index 0cac7df..d77cfd6 100644 --- a/core/modules/options/lib/Drupal/options/Plugin/field/field_type/ListBooleanItem.php +++ b/core/modules/options/lib/Drupal/options/Plugin/field/field_type/ListBooleanItem.php @@ -53,55 +53,6 @@ public static function schema(Field $field) { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { - $instance = $this->getInstance(); - $field = $instance->getField(); - $settings = $field->getFieldSettings(); - - $values = $settings['allowed_values']; - $off_value = array_shift($values); - $on_value = array_shift($values); - - $element['allowed_values'] = array( - '#type' => 'value', - '#description' => '', - '#value_callback' => 'options_field_settings_form_value_boolean_allowed_values', - '#access' => empty($settings['allowed_values_function']), - ); - $element['allowed_values']['on'] = array( - '#type' => 'textfield', - '#title' => t('On value'), - '#default_value' => $on_value, - '#required' => FALSE, - '#description' => t('If left empty, "1" will be used.'), - // Change #parents to make sure the element is not saved into field - // settings. - '#parents' => array('on'), - ); - $element['allowed_values']['off'] = array( - '#type' => 'textfield', - '#title' => t('Off value'), - '#default_value' => $off_value, - '#required' => FALSE, - '#description' => t('If left empty, "0" will be used.'), - // Change #parents to make sure the element is not saved into field - // settings. - '#parents' => array('off'), - ); - - // Link the allowed value to the on / off elements to prepare for the rare - // case of an alter changing #parents. - $element['allowed_values']['#on_parents'] = &$element['allowed_values']['on']['#parents']; - $element['allowed_values']['#off_parents'] = &$element['allowed_values']['off']['#parents']; - - $element += parent::settingsForm($form, $form_state, $element); - - return $element; - } - - /** - * {@inheritdoc} - */ public function getPropertyDefinitions() { if (!isset(static::$propertyDefinitions)) { static::$propertyDefinitions['value'] = array( diff --git a/core/modules/options/lib/Drupal/options/Plugin/field/field_type/ListFloatItem.php b/core/modules/options/lib/Drupal/options/Plugin/field/field_type/ListFloatItem.php index 8b53b0f..e5f6a75 100644 --- a/core/modules/options/lib/Drupal/options/Plugin/field/field_type/ListFloatItem.php +++ b/core/modules/options/lib/Drupal/options/Plugin/field/field_type/ListFloatItem.php @@ -40,15 +40,15 @@ class ListFloatItem extends ListItemBase { * {@inheritdoc} */ public static function schema(Field $field) { - return parent::schema($field) + array( - 'columns' => array( - 'value' => array( - 'type' => 'float', - 'not null' => FALSE, - ), + return parent::schema($field) + array( + 'columns' => array( + 'value' => array( + 'type' => 'float', + 'not null' => FALSE, ), - ); - } + ), + ); + } /** * {@inheritdoc} diff --git a/core/modules/options/lib/Drupal/options/Plugin/field/field_type/ListIntegerItem.php b/core/modules/options/lib/Drupal/options/Plugin/field/field_type/ListIntegerItem.php index a3c0372..dbc1d51 100644 --- a/core/modules/options/lib/Drupal/options/Plugin/field/field_type/ListIntegerItem.php +++ b/core/modules/options/lib/Drupal/options/Plugin/field/field_type/ListIntegerItem.php @@ -40,15 +40,15 @@ class ListIntegerItem extends ListItemBase { * {@inheritdoc} */ public static function schema(Field $field) { - return parent::schema($field) + array( - 'columns' => array( - 'value' => array( - 'type' => 'int', - 'not null' => FALSE, - ), + return parent::schema($field) + array( + 'columns' => array( + 'value' => array( + 'type' => 'int', + 'not null' => FALSE, ), - ); - } + ), + ); + } /** * {@inheritdoc} diff --git a/core/modules/options/lib/Drupal/options/Plugin/field/field_type/ListItemBase.php b/core/modules/options/lib/Drupal/options/Plugin/field/field_type/ListItemBase.php index e5d0f5d..da35e2c 100644 --- a/core/modules/options/lib/Drupal/options/Plugin/field/field_type/ListItemBase.php +++ b/core/modules/options/lib/Drupal/options/Plugin/field/field_type/ListItemBase.php @@ -19,17 +19,17 @@ * {@inheritdoc} */ public static function schema(Field $field) { - return array( - 'indexes' => array( - 'value' => array('value'), - ), - ); - } + return array( + 'indexes' => array( + 'value' => array('value'), + ), + ); + } /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state, $element = array()) { + public function settingsForm(array $form, array &$form_state) { $instance = $this->getInstance(); $field = $instance->getField(); $settings = $field->getFieldSettings(); @@ -60,6 +60,43 @@ public function settingsForm(array $form, array &$form_state, $element = array() $description .= '

'; $element['allowed_values']['#description'] = $description; } + elseif ($field['type'] == 'list_boolean') { + $values = $settings['allowed_values']; + $off_value = array_shift($values); + $on_value = array_shift($values); + + $element['allowed_values'] = array( + '#type' => 'value', + '#description' => '', + '#value_callback' => 'options_field_settings_form_value_boolean_allowed_values', + '#access' => empty($settings['allowed_values_function']), + ); + $element['allowed_values']['on'] = array( + '#type' => 'textfield', + '#title' => t('On value'), + '#default_value' => $on_value, + '#required' => FALSE, + '#description' => t('If left empty, "1" will be used.'), + // Change #parents to make sure the element is not saved into field + // settings. + '#parents' => array('on'), + ); + $element['allowed_values']['off'] = array( + '#type' => 'textfield', + '#title' => t('Off value'), + '#default_value' => $off_value, + '#required' => FALSE, + '#description' => t('If left empty, "0" will be used.'), + // Change #parents to make sure the element is not saved into field + // settings. + '#parents' => array('off'), + ); + + // Link the allowed value to the on / off elements to prepare for the rare + // case of an alter changing #parents. + $element['allowed_values']['#on_parents'] = &$element['allowed_values']['on']['#parents']; + $element['allowed_values']['#off_parents'] = &$element['allowed_values']['off']['#parents']; + } // Alter the description for allowed values depending on the widget type. if ($instance['widget']['type'] == 'options_onoff') { diff --git a/core/modules/options/lib/Drupal/options/Plugin/field/field_type/ListTextItem.php b/core/modules/options/lib/Drupal/options/Plugin/field/field_type/ListTextItem.php index a38ab41..0672bb6 100644 --- a/core/modules/options/lib/Drupal/options/Plugin/field/field_type/ListTextItem.php +++ b/core/modules/options/lib/Drupal/options/Plugin/field/field_type/ListTextItem.php @@ -40,16 +40,16 @@ class ListTextItem extends ListItemBase { * {@inheritdoc} */ public static function schema(Field $field) { - return parent::schema($field) + array( - 'columns' => array( - 'value' => array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => FALSE, - ), + return parent::schema($field) + array( + 'columns' => array( + 'value' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, ), - ); - } + ), + ); + } /** * {@inheritdoc}