class ChartsConfigForm in Charts 8.3
Same name in this branch
- 8.3 src/Form/ChartsConfigForm.php \Drupal\charts\Form\ChartsConfigForm
- 8.3 modules/charts_chartjs/src/Form/ChartsConfigForm.php \Drupal\charts_chartjs\Form\ChartsConfigForm
- 8.3 modules/charts_google/src/Form/ChartsConfigForm.php \Drupal\charts_google\Form\ChartsConfigForm
- 8.3 modules/charts_billboard/src/Form/ChartsConfigForm.php \Drupal\charts_billboard\Form\ChartsConfigForm
- 8.3 modules/charts_c3/src/Form/ChartsConfigForm.php \Drupal\charts_c3\Form\ChartsConfigForm
- 8.3 modules/charts_highcharts/src/Form/ChartsConfigForm.php \Drupal\charts_highcharts\Form\ChartsConfigForm
Charts Config Form.
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
- class \Drupal\charts_highcharts\Form\ChartsConfigForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of ChartsConfigForm
1 string reference to 'ChartsConfigForm'
- charts_highcharts.routing.yml in modules/
charts_highcharts/ charts_highcharts.routing.yml - modules/charts_highcharts/charts_highcharts.routing.yml
File
- modules/
charts_highcharts/ src/ Form/ ChartsConfigForm.php, line 12
Namespace
Drupal\charts_highcharts\FormView source
class ChartsConfigForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'charts_highcharts_settings';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'charts_highcharts.settings',
];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('charts_highcharts.settings');
$form['placeholder'] = [
'#title' => $this
->t('Placeholder'),
'#type' => 'fieldset',
'#description' => $this
->t('This is a placeholder for Highcharts-specific library options. If you would like to help build this out, please work from <a href="@issue_link">this issue</a>.', [
'@issue_link' => Url::fromUri('https://www.drupal.org/project/charts/issues/3046981')
->toString(),
]),
];
$form['legend'] = [
'#title' => $this
->t('Legend Settings'),
'#type' => 'fieldset',
];
$form['legend']['legend_layout'] = [
'#title' => $this
->t('Legend layout'),
'#type' => 'select',
'#options' => [
'vertical' => t('Vertical'),
'horizontal' => t('Horizontal'),
],
'#default_value' => $config
->get('legend_layout'),
];
$form['legend']['legend_background_color'] = [
'#title' => $this
->t('Legend background color'),
'#type' => 'textfield',
'#size' => 10,
'#maxlength' => 7,
'#attributes' => [
'placeholder' => t('transparent'),
],
'#description' => t('Leave blank for a transparent background.'),
'#default_value' => $config
->get('legend_background_color'),
];
$form['legend']['legend_border_width'] = [
'#title' => $this
->t('Legend border width'),
'#type' => 'select',
'#options' => [
0 => t('None'),
1 => 1,
2 => 2,
3 => 3,
4 => 4,
5 => 5,
],
'#default_value' => $config
->get('legend_border_width'),
];
$form['legend']['legend_shadow'] = [
'#title' => $this
->t('Legend shadow'),
'#type' => 'select',
'#options' => [
'FALSE' => t('Disabled'),
'TRUE' => t('Enabled'),
],
'#default_value' => $config
->get('legend_shadow'),
];
$form['legend']['item_style'] = [
'#title' => $this
->t('Item Style'),
'#type' => 'fieldset',
];
$form['legend']['item_style']['item_style_color'] = [
'#title' => $this
->t('Item style color'),
'#type' => 'textfield',
'#size' => 10,
'#maxlength' => 7,
'#attributes' => [
'placeholder' => '#333333',
],
'#description' => t('Leave blank for a dark gray font.'),
'#default_value' => $config
->get('item_style_color'),
];
$form['legend']['item_style']['text_overflow'] = [
'#title' => $this
->t('Text overflow'),
'#type' => 'select',
'#options' => [
'FALSE' => t('False'),
'ellipsis' => t('Ellipsis'),
],
'#default_value' => $config
->get('text_overflow'),
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->config('charts_highcharts.settings')
->set('placeholder', $form_state
->getValue('placeholder'))
->set('legend_layout', $form_state
->getValue('legend_layout'))
->set('legend_background_color', $form_state
->getValue('legend_background_color'))
->set('legend_border_width', $form_state
->getValue('legend_border_width'))
->set('legend_shadow', $form_state
->getValue('legend_shadow'))
->set('item_style_color', $form_state
->getValue('item_style_color'))
->set('text_overflow', $form_state
->getValue('text_overflow'))
->save();
parent::submitForm($form, $form_state);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ChartsConfigForm:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
ChartsConfigForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
ChartsConfigForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
ChartsConfigForm:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
ConfigFormBase:: |
public static | function |
Instantiates a new instance of this class. Overrides FormBase:: |
13 |
ConfigFormBase:: |
public | function | Constructs a \Drupal\system\ConfigFormBase object. | 11 |
ConfigFormBaseTrait:: |
protected | function | Retrieves a configuration object. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormBase:: |
protected | property | The config factory. | 1 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 1 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
protected | function | Gets the current user. | |
FormBase:: |
protected | function | Gets the request object. | |
FormBase:: |
protected | function | Gets the route match. | |
FormBase:: |
protected | function | Gets the logger for a specific channel. | |
FormBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
FormBase:: |
public | function | Resets the configuration factory. | |
FormBase:: |
public | function | Sets the config factory for this form. | |
FormBase:: |
public | function | Sets the request stack object to use. | |
FormBase:: |
public | function |
Form validation handler. Overrides FormInterface:: |
62 |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |