- Issue created by @mygumbo
- π¬π§United Kingdom joachim
I'd say use the hook that modifies the widget instead.
- πΊπΈUnited States mygumbo
Would that be hook_field_widget_complete_form_alter? Unsure how to target that specific field that uses the select widget for datetime.
- πΊπΈUnited States mygumbo
Does anyone have an example of modifying (any kind of) a profile field in the checkout pane? Thank you.
- π¬π§United Kingdom joachim
It actually sounds like you want the date field to so something fairly different to what it does OOTB.
What about a custom formatter? You can then set it up on a custom view mode, and IIRC you can select the view mode to use in the commerce checkout pane. - πΊπΈUnited States mygumbo
Thanks... I'm looking for something super simple - this works on the profile form itself:
case 'profile_registrant_edit_form': case 'profile_registrant_add_form': $form['field_date_of_birth']['widget'][0]['value']['#date_year_range'] = $max_age.':'.$min_age;
- Status changed to Fixed
29 days ago 6:37am 19 August 2025 - π¦πΊAustralia elc
As this is an inline form, using
hook_inline_entity_form_entity_form_alter
works well.<?php /** * Implements hook_inline_entity_form_entity_form_alter(). */ function MY_MODULE_inline_entity_form_entity_form_alter(&$entity_form, &$form_state) { // Alter the form to pre-fill and lock a couple fields. $is_target = ($entity_form['#entity_type'] == 'profile' && $entity_form['#bundle'] == 'member_signup'); if ($is_target) { $form['field_date_of_birth']['widget'][0]['value']['#date_year_range'] = $max_age . ':' . $min_age; } }
Automatically closed - issue fixed for 2 weeks with no activity.