47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Forms;
|
|
|
|
use App\Forms\CommonForm;
|
|
|
|
class CollectorForm extends CommonForm
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
public function getFormRule(string $action, string $field): string
|
|
{
|
|
switch ($field) {
|
|
case "trafficinfo_uid":
|
|
case "in":
|
|
case "out":
|
|
case "raw_in":
|
|
case "raw_out":
|
|
$rule = "required|neumeric";
|
|
break;
|
|
default:
|
|
$rule = parent::getFormRule($action, $field);
|
|
break;
|
|
}
|
|
return $rule;
|
|
}
|
|
public function getFormOption(string $field, array $options = ['options' => [], 'extras' => [], 'atttributes' => []]): array
|
|
{
|
|
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
|
switch ($field) {
|
|
case 'trafficinfo_uid':
|
|
foreach (service('trafficservice')->getEntities() as $entity) {
|
|
$tempOptions[$entity->getPK()] = $entity->getTitle();
|
|
}
|
|
$options['options'] = $tempOptions;
|
|
break;
|
|
default:
|
|
$options = parent::getFormOption($field, $options);
|
|
break;
|
|
}
|
|
return $options;
|
|
}
|
|
}
|