74 lines
1.8 KiB
PHP
74 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Forms\Equipment;
|
|
|
|
class LineForm extends EquipmentForm
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
public function action_init_process(string $action, array &$formDatas = []): void
|
|
{
|
|
$fields = [
|
|
"type",
|
|
"protocol",
|
|
"title",
|
|
"bandwith",
|
|
"start_at",
|
|
"end_at",
|
|
];
|
|
$filters = [
|
|
"type",
|
|
"protocol",
|
|
"status",
|
|
];
|
|
$indexFilter = $filters;
|
|
$batchjobFilters = ['type', 'protocol', 'status'];
|
|
$actionButtons = ['view' => ICONS['SEARCH']];
|
|
$batchjobButtons = [];
|
|
switch ($action) {
|
|
case 'create':
|
|
case 'create_form':
|
|
case 'modify':
|
|
case 'modify_form':
|
|
$fields = [...$fields, 'status'];
|
|
break;
|
|
case 'view':
|
|
$fields = [...$fields, 'status', 'created_at'];
|
|
break;
|
|
case 'index':
|
|
case 'download':
|
|
$fields = [...$fields, 'status', 'created_at'];
|
|
break;
|
|
}
|
|
$this->setFormFields($fields);
|
|
$this->setFormRules($action, $fields);
|
|
$this->setFormFilters($filters);
|
|
$this->setFormOptions($action, $filters, $formDatas);
|
|
$this->setIndexFilters($indexFilter);
|
|
$this->setBatchjobFilters($batchjobFilters);
|
|
$this->setActionButtons($actionButtons);
|
|
$this->setBatchjobButtons($batchjobButtons);
|
|
}
|
|
public function getFormRule(string $action, string $field, array $formRules): array
|
|
{
|
|
switch ($field) {
|
|
case "bandwith":
|
|
case "type":
|
|
case "protocol":
|
|
case "status":
|
|
case "start_at":
|
|
$formRules[$field] = "required|trim|string";
|
|
break;
|
|
case "end_at":
|
|
$formRules[$field] = "permit_empty|valid_date";
|
|
break;
|
|
default:
|
|
$formRules = parent::getFormRule($action, $field, $formRules);
|
|
break;
|
|
}
|
|
return $formRules;
|
|
}
|
|
}
|