You are here

function forena_report_parameter_config_form in Forena Reports 8

Same name and namespace in other branches
  1. 7.5 forena.report.inc \forena_report_parameter_config_form()
  2. 7.4 forena.report.inc \forena_report_parameter_config_form()

Implementation of hook_form Edits a single parameter config

Parameters

unknown $formid:

unknown $form_state:

$report_name string name of report to edit:

$id string name of parameter to edit:

Return value

multitype:multitype:boolean string multitype:string multitype:string multitype:string multitype:string Ambigous <An, string> multitype:string unknown

File

./forena.report.inc, line 1095

Code

function forena_report_parameter_config_form($formid, $form_state, $report_name, $id) {
  $r = Frx::Editor($report_name);

  // Set up basic control types.
  $control_types = array(
    'textfield' => 'Text',
    'hidden' => 'Hidden',
    'radios' => 'Radios',
    'checkbox' => 'Checkbox',
    'checkboxes' => 'Checkboxes',
    'select' => 'Select',
    'selectajax' => 'Select with Refresh',
    'multiselect' => 'Multi-Select',
    'multiselectajax' => 'Multi-select With Refresh',
  );

  // Supported module specific control types.
  if (\Drupal::moduleHandler()
    ->moduleExists('date_api')) {
    $control_types['date_select'] = 'Date Select';
  }
  if (\Drupal::moduleHandler()
    ->moduleExists('date_popup')) {
    $control_types['date_popup'] = 'Date Popup';
  }

  // @FIXME: drupal_set_title() has been removed in Drupal 8. Setting the title is now done in different ways depending on the context. For more information, see https://www.drupal.org/node/2067859
  // drupal_set_title($r->title);
  $form = array();
  $form['report_name'] = array(
    '#type' => 'value',
    '#value' => $report_name,
  );
  $parameters = $r->frxReport
    ->parametersArray();
  if (!isset($parameters[$id])) {
    drupal_not_found();
    drupal_exit();
  }
  $parm = $parameters[$id];

  //make a subtree for each param
  $form['parm'] = array(
    '#tree' => TRUE,
  );
  $form['parm']['id'] = array(
    '#type' => 'value',
    '#value' => $id,
  );
  $form['parm']['id_label'] = array(
    '#type' => 'item',
    '#title' => t('Name'),
    '#markup' => $id,
    '#description' => t('The machine friendly name of the parameter as used in the query or report.  '),
  );
  $form['parm']['label'] = array(
    '#type' => 'textfield',
    '#title' => t('label'),
    '#default_value' => @$parm['label'],
    '#required' => FALSE,
    '#description' => t('A descriptive name of the parameter to be displayed on a form.'),
  );
  $form['parm']['require'] = array(
    '#type' => 'radios',
    '#title' => t('require'),
    '#default_value' => @$parm['require'] ? $parm['require'] : "0",
    '#options' => array(
      "1" => t('Yes'),
      "0" => t('No'),
    ),
    '#description' => t('Requires a value for this parameter to display the report. If there is not a default value, the user will be prompted to enter a value.'),
  );
  $form['parm']['default'] = array(
    '#type' => 'textfield',
    '#title' => 'default value',
    '#default_value' => @$parm['default'],
    '#description' => t('The value of the parameter for the initial view of the report.'),
  );
  $form['parm']['desc'] = array(
    '#type' => 'textfield',
    '#title' => t('description'),
    '#default_value' => @$parm['desc'],
    '#description' => t('Enter a helpful description about this parameter. This will display on the form when the user is prompted to enter a parameter.'),
  );
  $form['parm']['type'] = array(
    '#type' => 'select',
    '#title' => t('Input Control Type'),
    '#default_value' => @$parm['type'],
    '#options' => $control_types,
    '#description' => t('Enter a helpful description about this parameter. This will display on the form when the user is prompted to enter a parameter.'),
  );
  $form['parm']['data_source'] = array(
    '#type' => 'textfield',
    '#title' => t('Source Data'),
    '#default_value' => @$parm['data_source'],
    '#autocomplete_path' => 'forena/data_block/autocomplete',
    '#description' => t('Data block to be used for select, multiselect, and checkboxes types'),
  );
  $form['parm']['data_field'] = array(
    '#type' => 'textfield',
    '#title' => t('Data Field'),
    '#default_value' => @$parm['data_field'],
    '#description' => t('Column in data block to be used data of select boxes and radio buttons. '),
  );
  $form['parm']['label_field'] = array(
    '#type' => 'textfield',
    '#title' => t('Label Field'),
    '#default_value' => @$parm['label_field'],
    '#description' => t('Column in data block to be used for the label for selet boxes and radio buttons.'),
  );
  $form['parm']['options'] = array(
    '#type' => 'textfield',
    '#title' => t('Options'),
    '#default_value' => @$parm['options'],
    '#description' => t('Used to configure the control type above options depend on the control type above.'),
  );
  $form['parm']['class'] = array(
    '#type' => 'textfield',
    '#title' => t('Class'),
    '#description' => t('Specify the html class you wish to apply to this parameter'),
    '#default_value' => @$parm['class'],
  );
  $form['update'] = array(
    '#type' => 'submit',
    '#value' => 'Update',
  );
  $form['cancel'] = array(
    '#type' => 'submit',
    '#value' => 'Cancel',
    '#submit' => array(
      'forena_update_cancel',
    ),
  );
  return $form;
}