How to add more Fields using Form Api I want to add an add more button to an element in Drupal form (using Drupal Form API). Should I make it with javascript (append a new element) and check for $_POST in submission or is there another solution in Drupal API.

This is my code for that field, I want users to be able to upload more than one image:

$form['product'] = array(
  '#title' =&gt; t('product'),
  '#type' =&gt; 'managed_file',
  '#required' =&gt; TRUE,
  '#default_value' =&gt; variable_get('product', ''),
  '#upload_location' =&gt; 'public://',
  '#upload_validators' =&gt; array(
    'file_validate_extensions' =&gt; array('gif png jpg jpeg'),
    'file_validate_size' =&gt; array(0.6*1024*1024),
  ),
);
Use Drupal's AJAX Form functionality to add elements to a form from the client.

If you try to update a Drupal form with JavaScript on the client side, it will not be submitted correctly. Drupal knows what was in the form when it was sent to the client, and expects that same structure to be sent back. Therefore, you need to use AJAX to tell Drupal the form is updated (with more fields, etc.).