Question: With the 'field collections' module at the form level, you can create a fieldset (or 'field group') that will accept multiple sets of values. 

![enter image description here](https://i.stack.imgur.com/xfNYE.png)

Is there a way to do this with the Form API directly (or with the help 'field collections' or 'field group' module) programmatically. I can make the form fieldset easy enough, but I'm not sure how to set multiple values for this set. In fact, I'm not really sure how you define multiple values for any field with the Form API.

UPDATE: Just to be clear I want to create the form, not the entity itself (at least not yet). I want to use the Form API to accomplish this to make my own `$form` – just the form.

Answer: 
Modify your example\_form\_form1\_submit function as follows

```
function example_form_form1_submit(&$form, &$form_state) {
  variable_set('id_event', $form_state['values']['id_event']);
  $id_event = variable_get('id_event', '');
  drupal_set_message($id_event);
}

```

![enter image description here](https://i.stack.imgur.com/SAYKM.png)
I resolved my problem using "system\_settings\_form($form);" since the solutions above did not work for me. (Will try later and if it works, will post any learnings here).

Following is what worked for me for reference:

My .module file:

```
function neil_menu() {

$items['admin/settings/neil'] = array(
    'title' => 'Node images',
    'description' => 'Control how to upload node images.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('neil_admin_settings'),
    'access arguments' => array('administer site configuration'),
    'file' => 'neil.admin.inc',
);
 return $items;

```

}

neil.admin.inc file:

```
function neil_admin_settings() {
   $form['progress_so_far'] = array(
'#type' => 'textfield',
'#title' => t('Progress So Far'),
'#default_value' => variable_get('progress_so_far', '0'),
'#maxlength' => 255,
);

return system_settings_form($form);
}

```