-
* initial refactoring to use address fieldsets on user creation and update * generalize user creation form ** allow for multiple addresses in more flexible ways ** introduce general radio fields for user groups * reuse dto on user creation with the help of zend-hydrator * adjust user update form * use hydrator for all user forms * fixup to user init method * add gpl license header * remove empty home library option from user update form * remove imports of non-existing classes * custom submit label in user update form * pass library list with ils authenticator * rename property for less confusion * implement possibly required ils authenticator method * render address id field only if value non-empty * convert user data property names to camel case via custom strategy * pass root input filter with context to nested input filters * relax requirements for first mandatory user address * first fixes to admin edit form * completely specify admin edit form in its own file * include job title field in admin edit form * revision of admin edit form
c8ffe802
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
admin-edit-form.php 7.81 KiB
<?php
/**
* Copyright (C) 2019 Leipzig University Library
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
*/
use fid\Hydrator\UserHydrator;
use fid\InputFilter\AdminEditFormInputFilter;
use fid\InputFilter\RootAwareBaseInputFilter;
use Zend\Filter\StringTrim;
use Zend\Form\Element\Collection;
use Zend\Form\Element\Hidden;
use Zend\Form\Element\Radio;
use Zend\Form\Element\Select;
use Zend\Form\Element\Submit;
use Zend\Form\Element\Text;
use Zend\Validator\Regex;
use Zend\Validator\StringLength;
return [
'name' => 'admin-edit-form',
'hydrator' => UserHydrator::class,
'elements' => [
'id' => [
'spec' => [
'name' => 'id',
'type' => Hidden::class,
],
],
'salutation' => [
'spec' => [
'name' => 'salutation',
'type' => Select::class,
'options' => [
'label' => 'label_salutation',
'options' => [
'mr' => [
'value' => 'mr',
'label' => 'label_salutation_mr',
],
'mrs' => [
'value' => 'mrs',
'label' => 'label_salutation_mrs',
]
],
'empty_option' => '',
],
],
],
'academic_title' => [
'spec' => [
'name' => 'academic_title',
'type' => Text::class,
'options' => [
'label' => 'label_academic_title',
],
],
],
'firstname' => [
'spec' => [
'name' => 'firstname',
'type' => Text::class,
'options' => [
'label' => 'label_firstname',
],
'attributes' => [
'required' => true,
],
],
],
'lastname' => [
'spec' => [
'name' => 'lastname',
'type' => Text::class,
'options' => [
'label' => 'label_lastname',
],
'attributes' => [
'required' => true,
],
],
],
'home_library' => [
'spec' => [
'name' => 'home_library',
'type' => Select::class,
'options' => [
'label' => 'label_home_library',
'use_hidden_element' => true,
],
'attributes' => [
'required' => true,
],
],
],
'college' => [
'spec' => [
'name' => 'college',
'type' => Text::class,
'options' => [
'label' => 'label_college',
]
],
],
'job_title' => [
'spec' => [
'name' => 'job_title',
'type' => Radio::class,
'options' => [
'label' => 'label_job_title',
'value_options' => [
'job_title_0',
'job_title_1'
],
],
'attributes' => [
'required' => true,
],
],
],
'permissions' => [
'spec' => [
'name' => 'permissions',
'type' => Collection::class,
'options' => [
'label' => 'label_permissions',
'target_element' => [
'name' => 'permission',
'type' => Select::class,
'options' => [
'value_options' => [
'denied' => 'permission_status_denied',
'requested' => 'permission_status_requested',
'granted' => 'permission_status_granted',
],
],
],
],
],
],
'submit' => [
'spec' => [
'name' => 'submit',
'type' => Submit::class,
'attributes' => [
'value' => 'label_update_submit',
],
],
],
],
'input_filter' => [
'type' => RootAwareBaseInputFilter::class,
'id' => [
'name' => 'id',
'required' => true,
],
'salutation' => [
'name' => 'salutation',
'required' => false,
'filters' => [
StringTrim::class => [
'name' => StringTrim::class,
],
],
],
'academic_title' => [
'name' => 'academic_title',
'required' => false,
'filters' => [
StringTrim::class => [
'name' => StringTrim::class,
],
],
],
'firstname' => [
'name' => 'firstname',
'required' => false,
'filters' => [
StringTrim::class => [
'name' => StringTrim::class,
],
],
'validators' => [
StringLength::class => [
'name' => StringLength::class,
'options' => [
'max' => 255
],
],
Regex::class => [
'name' => Regex::class,
'options' => [
'pattern' => '/^\D*$/',
],
],
],
],
'lastname' => [
'name' => 'lastname',
'required' => false,
'filters' => [
StringTrim::class => [
'name' => StringTrim::class,
],
],
'validators' => [
StringLength::class => [
'name' => StringLength::class,
'options' => [
'max' => 255
]
],
Regex::class => [
'name' => Regex::class,
'options' => [
'pattern' => '/^\D*$/',
],
],
],
],
'home_library' => [
'name' => 'home_library',
'filters' => [
StringTrim::class => [
'name' => StringTrim::class,
],
],
],
'college' => [
'name' => 'college',
'required' => false,
'filters' => [
StringTrim::class => [
'name' => StringTrim::class,
],
],
],
'job_title' => [
'name' => 'job_title',
'required' => true,
],
'submit' => [
'name' => 'submit',
'required' => true,
],
],
];