42 lines
1.4 KiB
PHP
42 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Helpers;
|
|
|
|
use App\Entities\UserEntity;
|
|
|
|
class UserHelper extends CommonHelper
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
|
{
|
|
switch ($field) {
|
|
case 'passwd':
|
|
case 'confirmpassword':
|
|
$form = form_password($field, "", [...$extras]);
|
|
break;
|
|
case 'role':
|
|
$currentRoles = is_array($value)
|
|
? array_map('strtolower', array_map('trim', $value))
|
|
: [];
|
|
$form = '';
|
|
//Form페이지에서는 맨앞에것 제외하기 위함
|
|
$firstOption = array_shift($viewDatas['formOptions'][$field]['options']);
|
|
foreach ($viewDatas['formOptions'][$field]['options'] as $key => $label) {
|
|
$checked = in_array(strtolower(trim($key)), $currentRoles);
|
|
$form .= '<label class="me-3">';
|
|
$form .= form_checkbox('role[]', $key, $checked, array_merge(['id' => "role_{$key}"], $extras));
|
|
$form .= " {$label}";
|
|
$form .= '</label>';
|
|
}
|
|
break;
|
|
default:
|
|
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
|
|
break;
|
|
}
|
|
return $form;
|
|
} //
|
|
}
|