public function JsonApiSettingsForm::buildForm in Drupal 10
Same name and namespace in other branches
- 8 core/modules/jsonapi/src/Form/JsonApiSettingsForm.php \Drupal\jsonapi\Form\JsonApiSettingsForm::buildForm()
- 9 core/modules/jsonapi/src/Form/JsonApiSettingsForm.php \Drupal\jsonapi\Form\JsonApiSettingsForm::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- core/
modules/ jsonapi/ src/ Form/ JsonApiSettingsForm.php, line 32
Class
- JsonApiSettingsForm
- Configure JSON:API settings for this site.
Namespace
Drupal\jsonapi\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$jsonapi_config = $this
->config('jsonapi.settings');
$form['read_only'] = [
'#type' => 'radios',
'#title' => $this
->t('Allowed operations'),
'#options' => [
'r' => $this
->t('Accept only JSON:API read operations.'),
'rw' => $this
->t('Accept all JSON:API create, read, update, and delete operations.'),
],
'#default_value' => $jsonapi_config
->get('read_only') === TRUE ? 'r' : 'rw',
'#description' => $this
->t('Warning: Only enable all operations if the site requires it. <a href=":docs">Learn more about securing your site with JSON:API.</a>', [
':docs' => 'https://www.drupal.org/docs/8/modules/jsonapi/security-considerations',
]),
];
return parent::buildForm($form, $form_state);
}