Skip to main content
2 of 4
improved formatting and punctuation
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

I got the solution from Save a new value with entity_metadata_wrapper to an entity field which is an array.

I created two separate form fields.

function createnode_form($form, &$form_state){ 
  $form['field_student_age'] = array(
    '#type' => 'textfield',
    '#title' => t('test'),
  );

  $form['field_student_age2'] = array(
    '#type' => 'textfield',
    '#title' => t('test2'),
  );

Then I stored them using the first method in the post quoted above.

$ewrapper->field_student_age[] = $form_state['values']['field_student_age'];
$ewrapper->field_student_age[] = $form_state['values']['field_student_age2'];

Rather than using set as I've done with single values, I created a new entry for each value using [] =.

Dominic Woodman
  • 2.2k
  • 4
  • 36
  • 60