public function ReadMore::settingsForm in CKEditor Read More 8
Same name and namespace in other branches
- 2.x src/Plugin/CKEditorPlugin/ReadMore.php \Drupal\ckeditor_readmore\Plugin\CKEditorPlugin\ReadMore::settingsForm()
Returns a settings form to configure this CKEditor plugin.
If the plugin's behavior depends on extensive options and/or external data, then the implementing module can choose to provide a separate, global configuration page rather than per-text-editor settings. In that case, this form should provide a link to the separate settings page.
Parameters
array $form: An empty form array to be populated with a configuration form, if any.
\Drupal\Core\Form\FormStateInterface $form_state: The state of the entire filter administration form.
\Drupal\editor\Entity\Editor $editor: A configured text editor object.
Return value
array A render array for the settings form.
Overrides CKEditorPluginConfigurableInterface::settingsForm
File
- src/
Plugin/ CKEditorPlugin/ ReadMore.php, line 106
Class
- ReadMore
- Defines the "Google Search" plugin.
Namespace
Drupal\ckeditor_readmore\Plugin\CKEditorPluginCode
public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
$settings = $editor
->getSettings();
//dd($settings);
$form['type'] = [
'#type' => 'radios',
'#title' => $this
->t('Type of read more element'),
'#description' => $this
->t('Choose between plain text and button'),
'#required' => true,
'#options' => [
'text' => $this
->t('Plain text'),
'button' => $this
->t('Button'),
],
'#default_value' => isset($settings['plugins']['readmore']['type']) ? $settings['plugins']['readmore']['type'] : 'text',
];
$form['more_text'] = [
'#type' => 'textfield',
'#title' => $this
->t('Text in read more element'),
'#description' => $this
->t('This text shows up in read more element'),
'#required' => true,
'#size' => 60,
'#maxlength' => 128,
'#default_value' => isset($settings['plugins']['readmore']['more_text']) ? $settings['plugins']['readmore']['more_text'] : $this
->t('Read more'),
];
$form['less_text'] = [
'#type' => 'textfield',
'#title' => $this
->t('Text in show less element'),
'#description' => $this
->t('This text shows up in show less element'),
'#required' => true,
'#size' => 60,
'#maxlength' => 128,
'#default_value' => isset($settings['plugins']['readmore']['less_text']) ? $settings['plugins']['readmore']['less_text'] : $this
->t('Show less'),
];
return $form;
}