Skip to content
Snippets Groups Projects
Commit f76d6af5 authored by Gregor Gawol's avatar Gregor Gawol Committed by Dorian Merz
Browse files

refs #16786 [fid_bbi] profile update form

* required false firstname, lastname and home_library
* fixed bug link to update form
* removed user/update.phtml as duplicate of instance/fid version
parent b70e5472
No related merge requests found
......@@ -30,6 +30,7 @@ $config = [
'forms' => [
'user-init-form' => require 'user-init-form.php',
'user-create-form' => require 'user-create-form.php',
'user-update-form' => require 'user-update-form.php',
],
'controllers' => [
'factories' => [
......
<?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>
* @author Gregor Gawol <gawol@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
*/
return [
'elements' => [
'firstname' => [
'spec' => [
'attributes' => [
'required' => false,
],
],
],
'lastname' => [
'spec' => [
'attributes' => [
'required' => false,
],
],
],
'home_library' => [
'spec' => [
'attributes' => [
'required' => false,
],
],
],
],
'input_filter' => [
'home_library' => [
'required' => false,
],
],
];
\ No newline at end of file
<?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 Gregor Gawol <gawol@ub.uni-leipzig.de>
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
*/
use fid\Service\DataTransferObject\Address;
use fid\Service\DataTransferObject\User;
use Zend\Form\Element as Element;
use Zend\Form\Element\Submit;
use Zend\Form\Form;
use Zend\Form\View\Helper\FormElementErrors;
use Zend\Form\View\Helper\FormLabel;
use Zend\Form\View\Helper\FormRadio;
use Zend\Form\View\Helper\FormSelect;
use Zend\Form\View\Helper\FormSubmit;
use Zend\I18n\Translator\TranslatorInterface;
/** @var FormLabel $formLabel */
$formLabel = $this->formLabel();
/**@var FormRadio $formRadio */
$formRadio = $this->formRadio();
/**@var FormSelect $formSelect */
$formSelect = $this->formSelect();
/**@var FormSubmit $formSubmit */
$formSubmit = $this->formSubmit();
/** @var FormElementErrors $formElementErrors */
$formElementErrors = $this->formElementErrors();
$formLabel->setTranslatorTextDomain('fid');
$formSelect->setTranslatorTextDomain('fid');
$formRadio->setTranslatorTextDomain('fid');
$formSubmit->setTranslatorTextDomain('fid');
$formElementErrors->setTranslatorTextDomain('fid');
/** @var TranslatorInterface $translator */
$translator = $this->getHelperPluginManager()->get('translate')
->getTranslator();
$formLabel->setTranslator($translator);
$formElementErrors->setTranslator($translator);
/** @var Form $form */
/** @var User $user */
$user = $this->user;
$form = $this->form;
$form->setAttribute('method', 'post');
$form->setAttribute('action', $this->url('fid/user/update'));
$form->setAttribute('class', 'form-horizontal');
$form->prepare();
$this->headTitle($this->translate('Profile Form'));
$this->headTitle($this->translate("fid::user_update_form_title"));
?>
<h2><?= $this->translate("fid::user_update_form_title") ?></h2>
<?= $this->flashmessages() ?>
<?= $this->form()->openTag($form) ?>
<br/>
<? /* home library */ ?>
<?php
/** @var Element\Select $elemHomeLibrary */
$elemHomeLibrary = $form->get('homeLibrary');
$elemHomeLibrary->setLabelAttributes(['class' => 'inline col-md-4 col-sm-10']);
$elemHomeLibrary->setAttributes(['class' => 'inline col-sm-6']);
$elemHomeLibrary->setValue($elemHomeLibrary->getValue() ?? $user->getHomeLibrary());
?>
<div class="form-group">
<?= $this->formLabel($elemHomeLibrary) ?>
<?= $this->formSelect($elemHomeLibrary) ?>
<?= $this->formElementErrors($elemHomeLibrary) ?>
</div>
<? /* salutation */ ?>
<?php
/** @var Element\Select $elemSalutation */
$elemSalutation = $form->get('salutation');
$elemSalutation->setAttribute('type', 'hidden');
echo $this->formElement($elemSalutation);
?>
<? /* academic title */ ?>
<?php
/** @var Element\Text $elemAcademicTitle */
$elemAcademicTitle = $form->get('academicTitle');
$elemAcademicTitle->setLabelAttributes(['class' => 'inline col-md-4 col-sm-10']);
$elemAcademicTitle->setAttributes(['class' => 'form-control']);
$elemAcademicTitle->setValue($elemAcademicTitle->getValue() ?? $user->getAcademicTitle());
?>
<div class="form-group">
<?= $this->formLabel($elemAcademicTitle) ?>
<?= $this->formElement($elemAcademicTitle) ?>
</div>
<? /* firstname */ ?>
<?php
/** @var Element\Text $elemFirstname */
$elemFirstname = $form->get('firstname');
$elemFirstname->setLabelAttributes(['class' => 'inline col-md-4 col-sm-10']);
$elemFirstname->setAttributes(['class' => 'form-control']);
$elemFirstname->setValue($elemFirstname->getValue() ?? $user->getFirstname());
?>
<div class="form-group">
<?= $this->formLabel($elemFirstname) ?>
<?= $this->formElement($elemFirstname) ?>
<?= $this->formElementErrors($elemFirstname) ?>
</div>
<? /* lastname */ ?>
<?php
/** @var Element\Text $elemLastname */
$elemLastname = $form->get('lastname');
$elemLastname->setLabelAttributes(['class' => 'inline col-md-4 col-sm-10']);
$elemLastname->setAttributes(['class' => 'form-control']);
$elemLastname->setValue($elemLastname->getValue() ?? $user->getLastname());
?>
<div class="form-group">
<?= $this->formLabel($elemLastname) ?>
<?= $this->formElement($elemLastname) ?>
<?= $this->formElementErrors($elemLastname) ?>
</div>
<? /* year of birth */ ?>
<?php
/** @var Element\Text $elemYearOfBirth */
$elemYearOfBirth = $form->get('yearOfBirth');
$elemYearOfBirth->setAttribute('type', 'hidden');
echo $this->formElement($elemYearOfBirth);
?>
<? /* college */ ?>
<?php
/** @var Element\Text $elemCollege */
$elemCollege = $form->get('college');
$elemCollege->setLabelAttributes(['class' => 'inline col-md-4 col-sm-10']);
$elemCollege->setAttributes(['class' => 'form-control']);
$elemCollege->setValue($elemCollege->getValue() ?? $user->getCollege());
?>
<div class="form-group">
<?= $this->formLabel($elemCollege) ?>
<?= $this->formElement($elemCollege) ?>
<?= $this->formElementErrors($elemCollege) ?>
</div>
<? /* job title */ ?>
<?php
/** @var Element\Text $elemJobTitle */
$elemJobTitle = $form->get('jobTitle');
$elemJobTitle->setAttribute('type', 'hidden');
echo $this->formElement($elemJobTitle);
?>
<? /* addresses */ ?>
<?= $this->render('update-addresses.phtml', compact('form', 'user')) ?>
<? /* submit button */ ?>
<?php
/** @var Submit $elemSubmit */
$elemSubmit = $form->get('submit');
$elemSubmit->setAttributes(['class' => 'btn btn-primary']);
?>
<div class="form-group">
<div class="col-lg-11 col-md-9 col-sm-11 col-xs-12">
<?= $this->formSubmit($elemSubmit) ?>
<a href="<?= $this->url('myresearch-profile') ?>"
class="btn btn-primary">
<?= $this->transEsc('Cancel') ?>
</a>
</div>
</div>
<?= $this->form()->closeTag($form) ?>
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