AdminOverviewForm.php in SMS Framework 8
File
modules/sms_sendtophone/src/Form/AdminOverviewForm.php
View source
<?php
namespace Drupal\sms_sendtophone\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\node\Entity\NodeType;
class AdminOverviewForm extends ConfigFormBase {
public function getFormId() {
return 'sms_sendtophone_admin_overview';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$node_types = NodeType::loadMultiple();
$types = [];
foreach ($node_types as $type) {
$types[$type
->get('type')] = $type
->get('name');
}
$form['content_types'] = [
'#type' => 'checkboxes',
'#title' => $this
->t('Content types'),
'#default_value' => $this
->config('sms_sendtophone.settings')
->get('content_types'),
'#options' => $types,
'#description' => $this
->t('Which content types to show the Send To Phone feature.'),
];
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->config('sms_sendtophone.settings')
->set('content_types', array_filter($form_state
->getValue('content_types')))
->save();
drupal_set_message($this
->t('The configuration options have been saved.'));
}
protected function getEditableConfigNames() {
return [
'sms_sendtophone.settings',
];
}
}