I'm creating a date widget that allows multiple date selection in one popup. I see in date_field_widget_form inside date_elements.inc that repeat dates skip creating elements for items with a $delta > 0.
if (!empty($field['settings']['repeat'])) {
if ($delta == 0) {
$form['#after_build'] = array('date_repeat_after_build');
$form_state['storage']['repeat_fields'][$field_name] = array_merge($form['#parents'], array($field_name));
$form_state['storage']['date_items'][$field_name][$langcode] = $items;
}
else {
return;
}
}If I understand this correctly, in my widget date_combo_process would create a new element for each item which I'll then have to hide later.
My suggestion is that we change this so that date_repeat_field implements hook_field_widget_properties_alter, checks the field settings, and adds flag to the widget such as 'multiple_field_behavior_custom' if it's a repeat field. Then other widgets could take advantage of this.
if (!empty($instance['widget']['multiple_field_behavior_custom])) {
if ($delta == 0) {
//can we put this somewhere else? I don't know
if (!empty($field['settings']['repeat']) {
$form['#after_build'] = array('date_repeat_after_build');
$form_state['storage']['repeat_fields'][$field_name] = array_merge($form['#parents'], array($field_name));
}
$form_state['storage']['date_items'][$field_name][$langcode] = $items;
}
else {
return;
}
}Does this make sense or am I barking up the wrong tree here. I'll write a patch.