Fixed a logic issue in Settings form

This commit is contained in:
Kyle Huynh 2023-02-07 11:13:01 -05:00
parent b1b0065c2a
commit ea2f01bce3

View file

@ -149,11 +149,6 @@ class SettingsForm extends ConfigFormBase {
->t('Enable Extended DisMax Query.'), ->t('Enable Extended DisMax Query.'),
'#description' => $this->t('If enabled, this applies to all fields searching in the Advanced Search Block.'), '#description' => $this->t('If enabled, this applies to all fields searching in the Advanced Search Block.'),
'#default_value' => self::getConfig(self::EDISMAX_SEARCH_FLAG, 1), '#default_value' => self::getConfig(self::EDISMAX_SEARCH_FLAG, 1),
'#ajax' => [
'callback' => '::LuceneSearchEnableDisableCallback',
'wrapper' => 'edismax-container',
'effect' => 'fade',
],
]; ];
$form['edismax']['textfields_container'] = [ $form['edismax']['textfields_container'] = [
@ -161,22 +156,19 @@ class SettingsForm extends ConfigFormBase {
'#attributes' => ['id' => 'edismax-container'], '#attributes' => ['id' => 'edismax-container'],
]; ];
if (self::getConfig(self::EDISMAX_SEARCH_FLAG, "All") === 1 $form['edismax']['textfields_container'][self::SEARCH_ALL_FIELDS_FLAG] = [
|| $form_state->getValue(self::EDISMAX_SEARCH_FLAG) === 1) { '#type' => 'checkbox',
$form['edismax']['textfields_container'][self::SEARCH_ALL_FIELDS_FLAG] = [ '#title' => $this
'#type' => 'checkbox', ->t('Enable searching all fields'),
'#title' => $this '#description' => $this->t('This will add an additional option (which label can be configured below) in Advanced Search block.'),
->t('Enable searching all fields'), '#default_value' => self::getConfig(self::SEARCH_ALL_FIELDS_FLAG, 0),
'#description' => $this->t('This will add an additional option (which label can be configured below) in Advanced Search block.'), ];
'#default_value' => self::getConfig(self::SEARCH_ALL_FIELDS_FLAG, 0), $form['edismax']['textfields_container'][self::EDISMAX_SEARCH_LABEL] = [
]; '#type' => 'textfield',
$form['edismax']['textfields_container'][self::EDISMAX_SEARCH_LABEL] = [ '#title' => $this->t('If enabled, set the label for the option of searching all fields'),
'#type' => 'textfield', '#description' => $this->t('This will apply for the additional option above in Advanced Search block.'),
'#title' => $this->t('If enabled, set the label for the option of searching all fields'), '#default_value' => self::getConfig(self::EDISMAX_SEARCH_LABEL, "All"),
'#description' => $this->t('This will apply for the additional option above in Advanced Search block.'), ];
'#default_value' => self::getConfig(self::EDISMAX_SEARCH_LABEL, "All"),
];
}
return parent::buildForm($form, $form_state); return parent::buildForm($form, $form_state);
} }
@ -202,13 +194,4 @@ class SettingsForm extends ConfigFormBase {
parent::submitForm($form, $form_state); parent::submitForm($form, $form_state);
} }
/**
* Callback for ajax_example_autotextfields.
*
* Selects the piece of the form we want to use as replacement markup and
* returns it as a form (renderable array).
*/
public function LuceneSearchEnableDisableCallback($form, FormStateInterface $form_state) {
return $form['edismax']['textfields_container'];
}
} }