Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
According to #2367229: html5 placeholder in date input field for view exposed filter and this it should looks like this:
/**
* Implements hook_date_popup_process_alter().
*/
function MODULENAME_date_popup_process_alter(&$element, &$form_state, $context) {
if ($form_state['complete form']['#form_id'] == 'ad_node_form') {
if ($element['#id'] == 'edit-field-born-date-ad-und-0-value-datepicker-popup-0') {
$element['date']['#attributes']['placeholder'][] = t('MM/DD/YYYY');
}
}
}
but it doesn't work. This is HTML code around my date field:
<div class="form-field-type-datetime form-field-name-field-born-date-ad field-widget-date-popup form-wrapper" id="edit-field-born-date-ad">
<div id="field-born-date-ad-add-more-wrapper">
<div class="form-item form-type-date-combo form-item-field-born-date-ad-und-0">
<div class="date-form-element-content">
<div class="date-no-float container-inline-date">
<div class="form-item form-type-date-popup form-item-field-born-date-ad-und-0-value">
<div id="edit-field-born-date-ad-und-0-value" class="date-padding">
<div class="form-item form-type-textfield form-item-field-born-date-ad-und-0-value-date">
<label for="edit-field-born-date-ad-und-0-value-datepicker-popup-0">Date of birth</label>
<input class="date-clear form-text" type="text" id="edit-field-born-date-ad-und-0-value-datepicker-popup-0" name="field_born_date_ad[und][0][value][date]" value="" size="20" maxlength="30" />
<div class="description"> MM/DD/YYYY (e.g.<em>09/18/2015</em>)</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Comment | File | Size | Author |
---|---|---|---|
#20 | date-2570697-20-generic-placeholder.patch | 893 bytes | JParkinson1991 |
#19 | date-n2570697-19.patch | 1.77 KB | DamienMcKenna |
| |||
#9 | date-added-placeholder-2570697-7.patch | 1.72 KB | harsha012 |
Comments
Comment #2
Vinay15Try using field name instead of id. This is something which I tried and succeeded :)
Comment #3
Vinay15Comment #4
jasom CreditAttribution: jasom commentedI did it using this code:
Comment #5
anpolimusTask without patch has wrong status.
Comment #6
harsha012 CreditAttribution: harsha012 as a volunteer commentedAdded to patch for the placeholder in the date popup
Comment #7
harsha012 CreditAttribution: harsha012 commentedComment #8
harsha012 CreditAttribution: harsha012 commentedComment #9
harsha012 CreditAttribution: harsha012 as a volunteer commentedAs per #6 patch. it was done for popup type. This is final patch for placeholder in the date fields.
Comment #10
harsha012 CreditAttribution: harsha012 commentedComment #11
harsha012 CreditAttribution: harsha012 commentedComment #12
harsha012 CreditAttribution: harsha012 as a volunteer and at Red Crackle commentedComment #13
sumanthkumarc CreditAttribution: sumanthkumarc as a volunteer commented@harsha012 Can you help me how to test this issue/patch?
Comment #14
harsha012 CreditAttribution: harsha012 as a volunteer and at Red Crackle commentedgit apply --index
Comment #15
harsha012 CreditAttribution: harsha012 as a volunteer and at Red Crackle commentedComment #16
sumanthkumarc CreditAttribution: sumanthkumarc as a volunteer commented@harsha012 steps to reproduce the issue
Comment #17
NWOM CreditAttribution: NWOM commented#9 worked great for me. Thank you!
@sumanthkumarc:
Comment #18
DamienMcKennaReminder: the "assigned" field is for indicating that you are actively working on something, it is not for indicating that you reported a problem or that you previously worked on a problem and would like attribution. Thanks.
Comment #19
DamienMcKennaRerolled.
Not sure if this should be added, though.
Comment #20
JParkinson1991 CreditAttribution: JParkinson1991 commentedUpdated patch allowing generic placeholders.
Simply checks existence of placeholder attribute definition on parent element and applies to the sub 'date' element where found.
Comment #22
DamienMcKennaThis seems simple and straight forward, thank you.