I'm trying to place "Add new item" button before the unlimited values field. Also two buttons un top and below field will work. In custom module added new button but it brakes AJAX call for both buttons. This is needed for Field collection field but I doubt it matters. This is how I've tried to build second button:

    $form['field_fieldname']['add_more2'] = array(
    '#type' => 'submit',
    '#name' => 'field_fieldname_add_more',
    '#value' => t('Add another item'),
    '#submit' => array('field_add_more_submit'),
    '#ajax' => array('callback'=>'field_add_more_js','wrapper'=>'field-fieldname-add-more-wrapper','effect'=>'fade',),
    '#limit_validation_errors' => array(array('field_fieldname','und')),
    '#attributes' => array('class'=>array('field-add-more-submit'))
  • you could use css to adjust the relative positions of the field and submit button, or use a line or two of jQuery to accomplish it as well, without having to create a whole new button
    – Geoff
    Jun 1, 2015 at 11:32

1 Answer 1


The function theme_field_multiple_value_form($variables) is used (by default) to generate the HTML for the multi-value field. In this function the 'Add another item' button is hardcoded after the table:

$output = '<div class="form-item">';
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => $table_id, 'class' => array('field-multiple-table'))));
$output .= $element['#description'] ? '<div class="description">' . $element['#description'] . '</div>' : '';
$output .= '<div class="clearfix">' . drupal_render($add_more_button) . '</div>';
$output .= '</div>';

So, what you could do is override the theme function, and print the rendering of '$add_more_button' before the rendering of the table.

As a side note: if you want to override the theme function using a custom module, you could use hook_theme_registry_alter(&$theme_registry) and set $theme_registry['field_multiple_value_form']['function'] to your customized "theme" function.

  • Thank You for direction. For multiple value field indeed this function override helps. In my case I needed to make adjustments in another theme function theme_field_collection_table_multiple_value_fields() and it comes from field_collection_table module which I use.
    – ctrnz
    Jun 2, 2015 at 16:48
  • Ok, good to hear my answer is useful.
    – Watergate
    Jun 3, 2015 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.