YouTubePluginForm.php in CKEditor Youtube 8
File
src/Form/YouTubePluginForm.php
View source
<?php
namespace Drupal\ckeditor_youtube\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\ConfigFormBase;
class YouTubePluginForm extends ConfigFormBase {
public function getFormId() {
return 'youtube_plugin_admin_form';
}
protected function getEditableConfigNames() {
return [
'ckeditor_youtube.settings',
];
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('ckeditor_youtube.settings');
$form['ckeditor_youtube_settings']['library_path'] = [
'#type' => 'textfield',
'#title' => $this
->t('Enter the path the CKEditor Youtube plugin is installed at.'),
'#required' => TRUE,
'#description' => $this
->t('By default this is "libraries/youtube".'),
'#default_value' => $config
->get('library_path'),
];
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
$this
->config('ckeditor_youtube.settings')
->set('library_path', $values['library_path'])
->save();
parent::submitForm($form, $form_state);
}
}