function date_repeat_after_build in Date 8
Same name and namespace in other branches
- 7.3 date_repeat_field/date_repeat_field.module \date_repeat_after_build()
- 7.2 date_repeat_field/date_repeat_field.module \date_repeat_after_build()
Implements the form after_build().
Remove the 'Add more' elements from a repeating date form.
2 string references to 'date_repeat_after_build'
- DateTextWidget::formElement in lib/
Drupal/ date/ Plugin/ field/ widget/ DateTextWidget.php - Implements Drupal\field\Plugin\Type\Widget\WidgetInterface::formElement().
- DateWidgetBase::formElement in lib/
Drupal/ date/ Plugin/ field/ widget/ DateWidgetBase.php - Implements Drupal\field\Plugin\Type\Widget\WidgetInterface::formElement().
File
- date_repeat_field/
date_repeat_field.module, line 398 - Creates the option of Repeating date fields and manages Date fields that use the Date Repeat API.
Code
function date_repeat_after_build(&$element, &$form_state) {
foreach ($form_state['storage']['repeat_fields'] as $field_name => $parents) {
// Remove unnecessary items in the form added by the Add more handling.
$value = drupal_array_get_nested_value($element, $parents);
$langcode = $value['#language'];
unset($value[$langcode]['add_more'], $value[$langcode]['#suffix'], $value[$langcode]['#prefix'], $value[$langcode][0]['_weight']);
$value[$langcode]['#cardinality'] = 1;
$value[$langcode]['#max_delta'] = 1;
drupal_array_set_nested_value($element, $parents, $value);
}
return $element;
}