Commit 2227d8e5 authored by o.tkach@internetdevels.com's avatar o.tkach@internetdevels.com
Browse files

rem patch

parent 3ecf1894
......@@ -215,17 +215,18 @@ function stat_form_user_register_form_alter(&$form, $form_state, $form_id) {
[':input[name="roles"]' => ['value' => 'client']],
]
];
$form["actions"]["submit"]["#submit"][] = 'stat_address_submit';
// array_unshift($form["actions"]["submit"]["#submit"], '');
// $form["#validate"][] = 'stat_addess_validate';
$form["actions"]["submit"]["#submit"][] = 'stat_address_submit';
}
function stat_address_submit(array $form, FormStateInterface $form_state) {
$role = $form_state->getValue('roles');
$roles = $role[0][0];
$owner_roles = [
'manager',
'analytic',
];
if (in_array($role, $owner_roles)) {
if (in_array($roles, $owner_roles)) {
$owner_id = $form_state->getValue('field_owner');
if (isset($owner_id[0]["target_id"])) {
$user = user_load_by_mail($form_state->getValue('mail'));
......@@ -235,4 +236,14 @@ function stat_address_submit(array $form, FormStateInterface $form_state) {
$user->save();
}
}
}
function stat_addess_validate(array $form, FormStateInterface &$form_state) {
// $role = $form_state->getValue('roles');
// $arr[0][] = $role;
// $arr2 = ["$role" => $role];
// $form_state->setValue('roles', $arr);
// $arr3 = $form_state->getUserInput();
// $arr3['roles'] = $arr2;
// $form_state->setUserInput($arr3);
}
\ No newline at end of file
Markdown is supported
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