Skip to content
Snippets Groups Projects
Commit cfef1671 authored by Kristof De Jaeger's avatar Kristof De Jaeger
Browse files

Issue #3344773 by swentel, mlncn, MegaKeegMan: ActivityPub Settings appears...

Issue #3344773 by swentel, mlncn, MegaKeegMan: ActivityPub Settings appears unable to save due to hidden required field makes "Older than" for "Remove old activities"
parent f0ba1afb
No related branches found
No related tags found
No related merge requests found
......@@ -259,12 +259,12 @@ class ActivityPubSettingsForm extends ConfigFormBase {
$form['inbox']['inbox_remove_x_days'] = [
'#type' => 'number',
'#min' => 0,
'#required' => TRUE,
'#title' => $this->t('Older than'),
'#field_suffix' => $this->t('days'),
'#default_value' => $config->get('inbox_remove_x_days'),
'#states' => [
'invisible' => ['input[name="inbox_remove_x_days_handler"]' => ['value' => FALSE]],
'required' => ['input[name="inbox_remove_x_days_handler"]' => ['!value' => FALSE]],
],
];
......@@ -323,6 +323,17 @@ class ActivityPubSettingsForm extends ConfigFormBase {
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
// Validate that inbox_remove_x_days is not empty when selecting a handler.
$inbox_remove_x_days_handler = $form_state->getValue('inbox_remove_x_days_handler');
if (!empty($inbox_remove_x_days_handler) && empty($form_state->getValue('inbox_remove_x_days'))) {
$form_state->setErrorByName('inbox_remove_x_days', $this->t('You can not set days to 0.'));
}
}
/**
* {@inheritdoc}
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment