cerebrate/templates/Users/add.php

99 lines
3.7 KiB
PHP
Raw Normal View History

2020-06-19 00:42:10 +02:00
<?php
use Cake\Core\Configure;
$passwordRequired = false;
$showPasswordField = false;
if ($this->request->getParam('action') === 'add') {
$dropdownData['individual'] = ['new' => __('New individual')] + $dropdownData['individual'];
if (!Configure::check('password_auth.enabled') || Configure::read('password_auth.enabled')) {
$passwordRequired = 'required';
}
}
if (!Configure::check('password_auth.enabled') || Configure::read('password_auth.enabled')) {
$showPasswordField = true;
}
2020-06-19 00:42:10 +02:00
echo $this->element('genericElements/Form/genericForm', [
'data' => [
'description' => __('Roles define global rules for a set of users, including first and foremost access controls to certain functionalities.'),
'model' => 'Roles',
'fields' => [
[
'field' => 'individual_id',
'type' => 'dropdown',
'label' => __('Associated individual'),
'options' => $dropdownData['individual']
],
[
'field' => 'individual.email',
'stateDependence' => [
'source' => '#individual_id-field',
'option' => 'new'
],
'required' => false
],
[
'field' => 'individual.first_name',
'label' => 'First name',
'stateDependence' => [
'source' => '#individual_id-field',
'option' => 'new'
],
'required' => false
],
[
'field' => 'individual.last_name',
'label' => 'Last name',
'stateDependence' => [
'source' => '#individual_id-field',
'option' => 'new'
],
'required' => false
],
2020-06-19 00:42:10 +02:00
[
'field' => 'username',
'autocomplete' => 'off'
2020-06-19 00:42:10 +02:00
],
[
'field' => 'organisation_id',
'type' => 'dropdown',
'label' => __('Associated organisation'),
'options' => $dropdownData['organisation'],
'default' => $loggedUser['organisation_id']
],
2020-06-19 00:42:10 +02:00
[
'field' => 'password',
'label' => __('Password'),
'type' => 'password',
'required' => $passwordRequired,
2021-11-26 10:53:24 +01:00
'autocomplete' => 'new-password',
'value' => '',
'requirements' => $showPasswordField,
2020-06-19 00:42:10 +02:00
],
[
'field' => 'confirm_password',
'label' => __('Confirm Password'),
'type' => 'password',
'required' => $passwordRequired,
'autocomplete' => 'off',
'requirements' => $showPasswordField,
2020-06-19 00:42:10 +02:00
],
2020-06-21 21:27:11 +02:00
[
'field' => 'role_id',
'type' => 'dropdown',
'label' => __('Role'),
'options' => $dropdownData['role'],
'default' => $defaultRole ?? null
2020-06-21 21:27:11 +02:00
],
2020-06-19 00:42:10 +02:00
[
'field' => 'disabled',
'type' => 'checkbox',
'label' => 'Disable'
]
],
'submit' => [
'action' => $this->request->getParam('action')
]
]
]);
?>
</div>