Skip to content

Commit

Permalink
Fix formatter form 'Illegal choice' error
Browse files Browse the repository at this point in the history
To reproduce:
- enable `Link to Item`, select a url field, and save
- remove the url field from the view
- go back to the view formatter settings and uncheck `Link to Item`
- try to save form

The form throws an illegal choice error for the url field even if `Link to Item` is disabled.
  • Loading branch information
amym-li authored Jun 16, 2023
1 parent 8212040 commit f44eb3f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/Plugin/views/style/FullCalendarSolr.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,25 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['item_url_field'] = [
'#type' => 'select',
'#title' => $this->t('Item URL Field'),
'#required' => $this->options['direct_to_item'],
'#options' => $view_fields_labels,
'#description' => $this->t('The selected field should contain a path or URL to the item.'),
'#default_value' => $this->options['item_url_field'],
'#states' => [
'enabled' => [
':input[data-drupal-selector="edit-style-options-fullcalendar-options-navlinks"]' => ['checked' => TRUE],
'and',
':input[data-drupal-selector="edit-style-options-direct-to-item"]' => ['checked' => TRUE],
'disabled' => [
[
':input[data-drupal-selector="edit-style-options-fullcalendar-options-navlinks"]' => ['checked' => FALSE],
],
'or',
[
':input[data-drupal-selector="edit-style-options-direct-to-item"]' => ['checked' => FALSE],
],
],
'required' => [
[
':input[data-drupal-selector="edit-style-options-fullcalendar-options-navlinks"]' => ['checked' => TRUE],
'and',
':input[data-drupal-selector="edit-style-options-direct-to-item"]' => ['checked' => TRUE],
],
],
],
];
Expand Down

0 comments on commit f44eb3f

Please sign in to comment.