You are here

function farm_flags_action_form in farmOS 7

Configuration form for farm_flags_action.

Parameters

array $context: The context passed into the action form function.

array $form_state: The form state passed into the action form function.

Return value

array Returns a form array.

File

modules/farm/farm_flags/farm_flags.module, line 164
Farm flags module.

Code

function farm_flags_action_form(array $context, array $form_state) {

  // Store the entity type in the form values.
  $form['entity_type'] = array(
    '#type' => 'value',
    '#value' => $context['entity_type'],
  );

  // Get a list of flag options.
  $flag_options = farm_flags_field_allowed_values();

  // Display a multi-select list.
  $form['flags'] = array(
    '#type' => 'select',
    '#title' => t('Flags'),
    '#description' => t('Select the flags that should be attached to the record(s).'),
    '#options' => $flag_options,
    '#multiple' => TRUE,
  );

  // Add a checkbox for appending the flags instead of overwriting them.
  $form['operation'] = array(
    '#type' => 'radios',
    '#title' => t('Append or Replace'),
    '#description' => t('Select "Append" if you want to add flags to the records, but keep existing flags. Select "Replace" if you want to replace existing flags with the ones specified above.'),
    '#options' => array(
      'append' => t('Append'),
      'replace' => t('Replace'),
    ),
    '#default_value' => 'append',
  );

  // Return the form.
  return $form;
}