diff --git a/core/modules/field/modules/number/number.module b/core/modules/field/modules/number/number.module index d00c55f..2340199 100644 --- a/core/modules/field/modules/number/number.module +++ b/core/modules/field/modules/number/number.module @@ -321,11 +321,29 @@ function number_field_widget_info() { 'number' => array( 'label' => t('Text field'), 'field types' => array('number_integer', 'number_decimal', 'number_float'), + 'settings' => array( + 'placeholder' => '', + ), ), ); } /** + * Implements hook_field_widget_settings_form(). + */ +function number_field_widget_settings_form($field, $instance) { + $form['placeholder'] = array( + '#type' => 'textfield', + '#title' => t('Placeholder'), + '#default_value' => $instance['widget']['settings']['placeholder'], + '#description' => t('The placeholder attribute represents a short hint (a word or short phrase) intended to aid the user with data entry. A hint could be a sample value or a brief description of the expected format.'), + '#weight' => -1, + ); + + return $form; +} + +/** * Implements hook_field_widget_form(). */ function number_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) { @@ -345,6 +363,7 @@ function number_field_widget_form(&$form, &$form_state, $field, $instance, $lang '#maxlength' => $field['type'] == 'number_decimal' ? $field['settings']['precision'] + 2 : 10, // Extract the number type from the field type name for easier validation. '#number_type' => str_replace('number_', '', $field['type']), + '#placeholder' => $instance['widget']['settings']['placeholder'], ); // Add prefix and suffix. diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 3a9258b..e4c719c 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -1375,6 +1375,7 @@ function taxonomy_field_widget_info() { 'label' => t('Autocomplete term widget (tagging)'), 'field types' => array('taxonomy_term_reference'), 'settings' => array( + 'placeholder' => '', 'size' => 60, 'autocomplete_path' => 'taxonomy/autocomplete', ), @@ -1386,6 +1387,20 @@ function taxonomy_field_widget_info() { } /** + * Implements hook_field_widget_settings_form(). + */ +function taxonomy_field_widget_settings_form($field, $instance) { + $form['placeholder'] = array( + '#type' => 'textfield', + '#title' => t('Placeholder'), + '#default_value' => $instance['widget']['settings']['placeholder'], + '#description' => t('The placeholder attribute represents a short hint (a word or short phrase) intended to aid the user with data entry. A hint could be a sample value or a brief description of the expected format.'), + ); + + return $form; +} + +/** * Implements hook_field_widget_info_alter(). */ function taxonomy_field_widget_info_alter(&$info) { @@ -1647,6 +1662,7 @@ function taxonomy_field_widget_form(&$form, &$form_state, $field, $instance, $la '#size' => $instance['widget']['settings']['size'], '#maxlength' => 1024, '#element_validate' => array('taxonomy_autocomplete_validate'), + '#placeholder' => $instance['widget']['settings']['placeholder'], ); return $element;