2020-06-19 00:42:10 +02:00
|
|
|
<?php
|
2022-02-25 00:33:00 +01:00
|
|
|
use Cake\Core\Configure;
|
|
|
|
$passwordRequired = false;
|
2022-03-01 13:59:10 +01:00
|
|
|
$showPasswordField = false;
|
2022-02-24 13:48:10 +01:00
|
|
|
if ($this->request->getParam('action') === 'add') {
|
|
|
|
$dropdownData['individual'] = ['new' => __('New individual')] + $dropdownData['individual'];
|
2022-02-25 00:33:00 +01:00
|
|
|
if (!Configure::check('password_auth.enabled') || Configure::read('password_auth.enabled')) {
|
|
|
|
$passwordRequired = 'required';
|
|
|
|
}
|
2022-02-24 13:48:10 +01:00
|
|
|
}
|
2022-03-01 13:59:10 +01:00
|
|
|
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']
|
|
|
|
],
|
2022-02-24 13:48:10 +01:00
|
|
|
[
|
|
|
|
'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
|
|
|
[
|
2020-11-06 09:21:44 +01:00
|
|
|
'field' => 'username',
|
|
|
|
'autocomplete' => 'off'
|
2020-06-19 00:42:10 +02:00
|
|
|
],
|
2021-11-24 01:25:57 +01:00
|
|
|
[
|
|
|
|
'field' => 'organisation_id',
|
|
|
|
'type' => 'dropdown',
|
|
|
|
'label' => __('Associated organisation'),
|
2022-01-27 21:54:59 +01:00
|
|
|
'options' => $dropdownData['organisation'],
|
|
|
|
'default' => $loggedUser['organisation_id']
|
2021-11-24 01:25:57 +01:00
|
|
|
],
|
2020-06-19 00:42:10 +02:00
|
|
|
[
|
|
|
|
'field' => 'password',
|
2020-06-25 02:11:56 +02:00
|
|
|
'label' => __('Password'),
|
2020-11-05 10:21:57 +01:00
|
|
|
'type' => 'password',
|
2022-02-25 00:33:00 +01:00
|
|
|
'required' => $passwordRequired,
|
2021-11-26 10:53:24 +01:00
|
|
|
'autocomplete' => 'new-password',
|
2022-02-25 00:33:00 +01:00
|
|
|
'value' => '',
|
2022-03-01 13:59:10 +01:00
|
|
|
'requirements' => $showPasswordField,
|
2020-06-19 00:42:10 +02:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'field' => 'confirm_password',
|
2020-06-25 02:11:56 +02:00
|
|
|
'label' => __('Confirm Password'),
|
2020-11-05 10:21:57 +01:00
|
|
|
'type' => 'password',
|
2022-02-25 00:33:00 +01:00
|
|
|
'required' => $passwordRequired,
|
|
|
|
'autocomplete' => 'off',
|
2022-03-01 13:59:10 +01:00
|
|
|
'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'),
|
2022-01-27 21:54:59 +01:00
|
|
|
'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'
|
2022-09-21 10:08:40 +02:00
|
|
|
],
|
2020-06-19 00:42:10 +02:00
|
|
|
],
|
|
|
|
'submit' => [
|
|
|
|
'action' => $this->request->getParam('action')
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]);
|
|
|
|
?>
|
|
|
|
</div>
|