dbms/app/Helpers/Device/DeviceHelper.php
2025-05-09 18:46:54 +09:00

41 lines
1.4 KiB
PHP

<?php
namespace App\Helpers\Device;
use App\Helpers\CommonHelper;
use CodeIgniter\HTTP\IncomingRequest;
class DeviceHelper extends CommonHelper
{
public function __construct(?IncomingRequest $request = null)
{
parent::__construct($request);
}
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
{
if (in_array($viewDatas['action'], ['create', 'modify'])) {
$extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
}
switch ($field) {
case "serverinfo_uid":
if (!is_array($viewDatas['field_options'][$field])) {
throw new \Exception(__METHOD__ . "에서 {$field}의 field_options가 array형태가 아닙니다.");
}
$formOptions = array_merge(
["" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택'],
$viewDatas['field_options'][$field]
);
$form = form_dropdown($field, $formOptions, $value, $extras);
break;
default:
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
break;
}
return $form;
} //
public function getListRowColor(mixed $entity, string $field = 'status', string $value = 'use'): string
{
return $entity->isMatched($field, $value) ? "" : 'class="table-danger"';
}
}