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' => t('product'),
'#type' => 'managed_file',
'#required' => TRUE,
'#default_value' => variable_get('product', ''),
'#upload_location' => 'public://',
'#upload_validators' => array(
'file_validate_extensions' => array('gif png jpg jpeg'),
'file_validate_size' => array(0.6*1024*1024),
),
);