<?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 Zend\Filter\StringTrim; use Zend\Filter\ToInt; use Zend\Filter\ToNull; use Zend\Form\Element\Number; use Zend\Form\Element\Select; use Zend\Form\Element\Submit; use Zend\Form\Element\Text; use Zend\Hydrator\ClassMethods; use Zend\Validator\Regex; use Zend\Validator\StringLength; return [ 'hydrator' => ClassMethods::class, 'elements' => [ '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' => '', ], ], ], 'academicTitle' => [ 'spec' => [ 'name' => 'academicTitle', 'type' => Text::class, 'options' => [ 'label' => 'label_academic_title', ], ], ], 'firstname' => [ 'spec' => [ 'name' => 'firstname', 'type' => Text::class, 'options' => [ 'label' => 'label_firstname', ], 'attributes' => [ 'required' => 'required', ], ], ], 'lastname' => [ 'spec' => [ 'name' => 'lastname', 'type' => Text::class, 'options' => [ 'label' => 'label_lastname', ], 'attributes' => [ 'required' => 'required', ], ], ], 'homeLibrary' => [ 'spec' => [ 'name' => 'homeLibrary', 'type' => Select::class, 'options' => [ 'label' => 'label_home_library', 'empty_option' => '', ], 'attributes' => [ 'required' => 'required', ], ], ], 'yearOfBirth' => [ 'spec' => [ 'name' => 'yearOfBirth', 'type' => Number::class, 'options' => [ 'label' => 'label_year_of_birth', ], 'attributes' => [ 'min' => 1900, 'max' => 2018, ], ] ], 'jobTitle' => [ 'spec' => [ 'name' => 'jobTitle', 'type' => Text::class, 'options' => [ 'label' => 'label_job_title', ], ], ], 'college' => [ 'spec' => [ 'name' => 'college', 'type' => Text::class, 'options' => [ 'label' => 'label_college', ] ], ], 'submit' => [ 'spec' => [ 'name' => 'submit', 'type' => Submit::class, 'attributes' => [ 'value' => 'label_submit', ], ], ], ], 'input_filter' => [ 'salutation' => [ 'name' => 'salutation', 'required' => false, 'filters' => [ StringTrim::class => [ 'name' => StringTrim::class, ], ], ], 'academicTitle' => [ 'name' => 'academicTitle', 'required' => false, 'filters' => [ StringTrim::class => [ 'name' => StringTrim::class, ], ], ], 'firstname' => [ 'name' => 'firstname', 'required' => true, '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' => true, 'filters' => [ StringTrim::class => [ 'name' => StringTrim::class, ], ], 'validators' => [ StringLength::class => [ 'name' => StringLength::class, 'options' => [ 'max' => 255 ] ], Regex::class => [ 'name' => Regex::class, 'options' => [ 'pattern' => '/^\D*$/', ], ], ], ], 'homeLibrary' => [ 'name' => 'homeLibrary', 'required' => true, 'filters' => [ StringTrim::class => [ 'name' => StringTrim::class, ], ], ], 'yearOfBirth' => [ 'name' => 'yearOfBirth', 'required' => false, 'filters' => [ ToNull::class => [ 'name' => ToNull::class, ], ToInt::class => [ 'name' => ToInt::class, ], ], ], 'jobTitle' => [ 'name' => 'jobTitle', 'required' => false, 'filters' => [ StringTrim::class => [ 'name' => StringTrim::class, ], ], ], 'college' => [ 'name' => 'college', 'required' => false, 'filters' => [ StringTrim::class => [ 'name' => StringTrim::class, ], ], ], 'submit' => [ 'name' => 'submit', 'required' => true, ], ], ];