You are here

function _makemeeting_choice_form in Make Meeting Scheduler 7.2

Helper function to construct a row of the widget form

Parameters

$key:

string $value:

array $suggestions:

int $size:

Return value

array

1 call to _makemeeting_choice_form()
makemeeting_field_widget_form in ./makemeeting.field.inc
Implements hook_field_widget_form().

File

./makemeeting.field.inc, line 258
This file is mostly about the field configuration.

Code

function _makemeeting_choice_form($key, $value = '', $suggestions = array(), $size = 1) {
  $form = array(
    '#tree' => TRUE,
  );

  // We'll manually set the #parents property of these fields so that
  // their values appear in the $form_state['values']['choices'] array
  // They are to be updated later in #process as we don't know here the
  // hierarchy of the parents
  $form['chdate'] = array(
    '#type' => 'date',
    '#title' => t('Date'),
    '#title_display' => 'invisible',
    '#default_value' => $value,
    '#parents' => array(
      'choices',
      $key,
      'chdate',
    ),
  );
  $form['chremove'] = array(
    '#type' => 'submit',
    '#parents' => array(),
    '#submit' => array(
      'makemeeting_choices_submit',
    ),
    '#limit_validation_errors' => array(
      array(
        'choices',
      ),
    ),
    '#ajax' => array(
      'callback' => 'makemeeting_choice_js',
      'wrapper' => 'makemeeting-choices-wrapper',
      'effect' => 'fade',
    ),
    '#value' => t('Remove'),
    // Assigning key as name to make each 'Remove' button unique
    '#name' => $key,
  );
  $form['chsuggestions'] = array(
    '#tree' => TRUE,
    '#parents' => array(
      'choices',
      $key,
      'chsuggestions',
    ),
  );
  for ($i = 0; $i < $size; $i++) {
    $key2 = 'sugg:' . $i;
    $form['chsuggestions'][$key2] = array(
      '#type' => 'textfield',
      '#title_display' => 'invisible',
      '#default_value' => isset($suggestions[$key2]) ? $suggestions[$key2] : '',
      '#size' => 5,
      '#maxlength' => 255,
      '#parents' => array(
        'choices',
        $key,
        'chsuggestions',
        $key2,
      ),
    );
  }
  return $form;
}