public function EnvironmentIndicatorFormController::form in Environment Indicator 8.2
This actually builds your form.
File
- lib/
Drupal/ environment_indicator/ EnvironmentIndicatorFormController.php, line 11
Class
Namespace
Drupal\environment_indicatorCode
public function form(array $form, array &$form_state) {
$environment_indicator = $this->entity;
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => $environment_indicator
->label(),
);
$form['machine'] = array(
'#type' => 'machine_name',
'#machine_name' => array(
'source' => array(
'name',
),
'exists' => 'environment_indicator_load',
),
'#default_value' => $environment_indicator
->id(),
'#disabled' => !empty($environment_indicator->machine),
);
$form['regexurl'] = array(
'#type' => 'textfield',
'#title' => t('Hostname'),
'#description' => t('The hostname you want to detect. You can use a regular expression in this field. This regular expression will be run against the current URL to determine wether the environment is active or not. If you use a regular expression here this environment will <strong>not be availabe</strong> for environment switch.'),
'#default_value' => $environment_indicator->regexurl,
);
$form['color_picker'] = array(
'#markup' => '<div id="environment-indicator-color-picker"></div>',
);
$form['color'] = array(
'#type' => 'textfield',
'#title' => t('Color'),
'#description' => t('Color for the indicator. Ex: #D0D0D0.'),
'#default_value' => $environment_indicator->color ?: '#D0D0D0',
'#attached' => array(
// Add Farbtastic color picker.
'library' => array(
'core/jquery.farbtastic',
),
),
);
$form['help'] = array(
'#markup' => t('You don\'t need to care about position and fixed if you are using the toolbar. If you use the toolbar module, then the environment indicator will be integrated.'),
);
$form['position'] = array(
'#title' => t('Position'),
'#descripyion' => t('Wether you want the indicator at the top or at the bottom.'),
'#type' => 'radios',
'#options' => array(
'top' => t('Top'),
'bottom' => t('Bottom'),
),
'#default_value' => $environment_indicator->position,
);
$form['fixed'] = array(
'#title' => t('Fixed'),
'#descripyion' => t('Check this if you want the indicator to be positioned fixed.'),
'#type' => 'checkbox',
'#default_value' => $environment_indicator->fixed,
);
return $form;
}