Вопрос

Is it possible and how to implement one textfield with multiple values in drupal form?

Say, I have the next code:

function mymodule_admin_settings() {
  $form['email'] = array(
    '#type' => 'fieldset',
    // ...
  );
  $form['email']['mymodule_email_recepient'] = array(
    '#type' => 'textfield',
    '#title' => t('Recepient'),
    '#default_value' => variable_get('mymodule_email_recepient', 'email@domain.com'),
    '#element_validate' => array('mymodule_email_validation'),
    '#maxlength' => 30,
    '#required' => TRUE,
  );
  // ...
  return system_settings_form($form);
}

What should I change for this form

  1. to show multiple textfields, e.g.

    <input name="mymodule_email_recepient[]" type="text" />;

  2. to call variable_set('mymodule_email_recepient', array( /*some values*/ )) on submit.

Thanks for advance!

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top