Loading live_data_gsheet.routing.yml +8 −0 Original line number Diff line number Diff line Loading @@ -7,3 +7,11 @@ live_data_gsheet.content: _permission: 'access content' options: no_cache: 'TRUE' live_data_gsheet.gsheet_url: path: /admin/config/gsheet-url defaults: _title: 'Setting for google Sheet' _form: \Drupal\live_data_gsheet\Form\GsheetSettingsForm requirements: _permission: 'administer site configuration' src/Form/GsheetSettingsForm.php 0 → 100644 +51 −0 Original line number Diff line number Diff line <?php namespace Drupal\live_data_gsheet\Form; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; /** * Configure Google Sheet url settings for this. */ class GsheetSettingsForm extends ConfigFormBase { /** * {@inheritdoc} */ public function getFormId() { return 'gsheet_settings'; } /** * {@inheritdoc} */ protected function getEditableConfigNames() { return ['gsheet.settings']; } /** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $form['gsheet_url'] = [ '#type' => 'textfield', '#title' => $this->t('Google Sheet URL'), '#default_value' => $this->config('gsheet.settings')->get('gsheet_url'), ]; return parent::buildForm($form, $form_state); } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('gsheet.settings') ->set('gsheet_url', $form_state->getValue('gsheet_url')) ->save(); parent::submitForm($form, $form_state); } } Loading
live_data_gsheet.routing.yml +8 −0 Original line number Diff line number Diff line Loading @@ -7,3 +7,11 @@ live_data_gsheet.content: _permission: 'access content' options: no_cache: 'TRUE' live_data_gsheet.gsheet_url: path: /admin/config/gsheet-url defaults: _title: 'Setting for google Sheet' _form: \Drupal\live_data_gsheet\Form\GsheetSettingsForm requirements: _permission: 'administer site configuration'
src/Form/GsheetSettingsForm.php 0 → 100644 +51 −0 Original line number Diff line number Diff line <?php namespace Drupal\live_data_gsheet\Form; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; /** * Configure Google Sheet url settings for this. */ class GsheetSettingsForm extends ConfigFormBase { /** * {@inheritdoc} */ public function getFormId() { return 'gsheet_settings'; } /** * {@inheritdoc} */ protected function getEditableConfigNames() { return ['gsheet.settings']; } /** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $form['gsheet_url'] = [ '#type' => 'textfield', '#title' => $this->t('Google Sheet URL'), '#default_value' => $this->config('gsheet.settings')->get('gsheet_url'), ]; return parent::buildForm($form, $form_state); } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('gsheet.settings') ->set('gsheet_url', $form_state->getValue('gsheet_url')) ->save(); parent::submitForm($form, $form_state); } }