You are here

function farm_log_asset_action_form in farmOS 7

Configuration form for farm_log_asset_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_log/farm_log.module, line 99
Code for the Farm Log feature.

Code

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

  // Load a list of all available log types.
  $log_types = log_types();

  // Get information about field instances on logs.
  $field_instances = field_info_instances('log');

  // Build a list of log type options.
  $log_type_options = array();
  foreach ($log_types as $log_type => $info) {

    // If this log type does not have field_farm_asset, skip it.
    if (empty($field_instances[$log_type]['field_farm_asset'])) {
      continue;
    }

    // Add the log type to the list of options.
    $log_type_options[$log_type] = $info->label;
  }

  // Log type select list.
  $form['log_type'] = array(
    '#type' => 'select',
    '#title' => t('Log type'),
    '#description' => t('What type of log would you like to create?'),
    '#options' => $log_type_options,
    '#required' => TRUE,
  );

  // Return the form.
  return $form;
}