Skip to content

Commit

Permalink
Adjust Feedback/form.phtml to allow overriding the default action rou…
Browse files Browse the repository at this point in the history
…te (#4187)
  • Loading branch information
LuomaJuha authored Jan 16, 2025
1 parent 9f78f74 commit da72b24
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 2 additions & 0 deletions config/vufind/FeedbackForms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# title (string) Form title (translation key)
# onlyForLoggedUsers (boolean) Require the user to be logged in to see the form
# (default = false)
# formActionRoute (string) Sets the route to which form data should be posted. (default = feedback-form)
# emailSubject (string) Email subject (translation key). (default = email_subject
# value from config.ini [Feedback] section, or 'VuFind Feedback')
# The subject may contain placeholders (for example %%receiver%%)
Expand Down Expand Up @@ -163,6 +164,7 @@ forms:
useCaptcha: true
reportReferrer: false
reportUserAgent: true
#formActionRoute: controller-route
#emailFrom:
# name: Your Library - Site Feedback
#recipient:
Expand Down
10 changes: 10 additions & 0 deletions module/VuFind/src/VuFind/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,16 @@ public function getFormElementConfig(): array
return $this->formElementConfig;
}

/**
* Return form action route if set in config
*
* @return string Form action route or feedback-form as default
*/
public function getFormActionRoute(): string
{
return $this->formConfig['formActionRoute'] ?? 'feedback-form';
}

/**
* Return form recipient(s).
*
Expand Down
5 changes: 2 additions & 3 deletions themes/bootstrap3/templates/feedback/form.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
$form->prepare();

$title = $form->getTitle();
$title = !empty($title)
? $this->translate($title) : null;
$title = !empty($title) ? $this->translate($title) : null;

$formUrl = $this->url('feedback-form', ['id' => $this->formId]);
$formUrl = $this->url($form->getFormActionRoute(), ['id' => $this->formId]);
$form->setAttribute('action', $formUrl);
$form->setAttribute('class', 'dynamic-form');
$form->setAttribute('method', 'post');
Expand Down
5 changes: 2 additions & 3 deletions themes/bootstrap5/templates/feedback/form.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
$form->prepare();

$title = $form->getTitle();
$title = !empty($title)
? $this->translate($title) : null;
$title = !empty($title) ? $this->translate($title) : null;

$formUrl = $this->url('feedback-form', ['id' => $this->formId]);
$formUrl = $this->url($form->getFormActionRoute(), ['id' => $this->formId]);
$form->setAttribute('action', $formUrl);
$form->setAttribute('class', 'dynamic-form');
$form->setAttribute('method', 'post');
Expand Down

0 comments on commit da72b24

Please sign in to comment.