Commit c8eea2ef authored by lazzyvn's avatar lazzyvn Committed by Renato Gonçalves H
Browse files

Issue #3062479 by lazzyvn, ciss, RenatoG, tawellman: bug form #max_delta

parent 1b1d38dd
......@@ -1463,13 +1463,14 @@ function field_collection_field_attach_form($entity_type, $entity, &$form, &$for
&& field_access('edit', $field, $entity_type)) {
$element_langcode = $form[$field_name]['#language'];
if ($form[$field_name][$element_langcode]['#max_delta'] > 0) {
if (!empty($form[$field_name][$element_langcode]['#max_delta']) && $form[$field_name][$element_langcode]['#max_delta'] > 0) {
$form[$field_name][$element_langcode]['#max_delta']--;
}
// Remove blank form elements and force user to explicitly add a field
// collection if both 'hide_initial_item' and 'hide_blank_items' are TRUE.
if ($field['settings']['hide_initial_item']
&& $field['settings']['hide_blank_items']
&& !empty($form[$field_name][$element_langcode][0]['#entity'])
&& $form[$field_name][$element_langcode][0]['#entity'] instanceof FieldCollectionItemEntity
&& field_collection_item_is_empty($form[$field_name][$element_langcode][0]['#entity'])) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment