function custom_add_another_preprocess_field_multiple_value_form in Custom add another 8
Same name and namespace in other branches
- 7 custom_add_another.module \custom_add_another_preprocess_field_multiple_value_form()
Implements hook_preprocess_field_multiple_value_form().
We look for a value that was placed there earlier by custom_add_another_field_widget_form_alter() and change the add_more button to use that.
File
- ./
custom_add_another.module, line 131 - Allows the 'Add another item' button text to be customised.
Code
function custom_add_another_preprocess_field_multiple_value_form(&$variables) {
foreach (Element::children($variables['element']) as $child) {
$child_element =& $variables['element'][$child];
if (isset($child_element['#custom_add_another_value']) || isset($child_element['#custom_remove'])) {
if (isset($child_element['#custom_add_another_value']) && isset($variables['element']['add_more']['#value']) && $variables['element']['add_more']['#value'] != t($child_element['#custom_add_another_value'])) {
$variables['element']['add_more']['#value'] = t($child_element['#custom_add_another_value']);
}
if (isset($child_element['#custom_add_another_value']) && isset($variables['button']['#value']) && $variables['button']['#value'] != t($child_element['#custom_add_another_value'])) {
$variables['button']['#value'] = t($child_element['#custom_add_another_value']);
}
if (isset($child_element['#custom_remove']) && isset($child_element['remove_button']['#value'])) {
$child_element['remove_button']['#value'] = t($child_element['#custom_remove']);
}
}
}
}