Skip to content
Snippets Groups Projects
Commit 7705225b authored by Dorian Merz's avatar Dorian Merz Committed by Robert Lange
Browse files

refs #18513 [fid] provide optional reordering of job_titles in forms

parent db5f5787
No related merge requests found
......@@ -29,4 +29,11 @@ permission_options[] = 'limited_access'
permission_options[] = 'full_access'
; file prefix for CSV export
user_list_export_file_prefix = 'export'
\ No newline at end of file
user_list_export_file_prefix = 'export'
[Forms]
; jobTitleOptions is applied to add new Job Titles or reorder them on the form
; provides a comma separated list of available options e.g. "0,2,1" will result
; in having options job_title_0, job_title_2, job_title_1 in that particular order
; of not given, options will be job_title_0, job_title_1
;jobTitleOptions = "0,1"
\ No newline at end of file
......@@ -198,6 +198,8 @@ class UserController extends AbstractBase
$homeLibraryElement = $form->get('home_library');
$homeLibraryElement->setValueOptions($libraries);
$this->applyJobTitleOptions($form);
if ($this->formWasSubmitted()) {
$form->setData($request->getPost());
if ($form->isValid()) {
......@@ -638,6 +640,8 @@ class UserController extends AbstractBase
$homeLibraryElement->setValueOptions($libraries);
$homeLibraryElement->setUnselectedValue($user->getHomeLibrary());
$this->applyJobTitleOptions($form);
if ($this->formWasSubmitted()) {
$form->setData($request->getPost());
if ($form->isValid()) {
......@@ -781,4 +785,18 @@ class UserController extends AbstractBase
return $response;
}
protected function applyJobTitleOptions($form)
{
if ($jobTitleOptions = $this->config['Forms']['jobTitleOptions'] ?? null) {
$options = [];
foreach (explode(',',$jobTitleOptions) as $jobTitleOption) {
$options[] = [
'value' => $jobTitleOption,
'label' => 'job_title_'.$jobTitleOption,
];
}
$jobTitleElement = $form->get('job_title');
$jobTitleElement->setValueOptions($options);
}
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment