1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace App\Admin\Forms;
- use App\Admin\Renderable\DistDistributorTable;
- use App\Admin\Repositories\DistAppearance;
- use Dcat\Admin\Widgets\Form;
- use App\Admin\Repositories\DistAppearanceVariable;
- class AceRight extends Form
- {
- public $distId;
- public $appearanceId;
- public $templateId;
- public function __construct($distId,$appearanceId,$templateId)
- {
- $this->distId = empty($distId) ? 0 : $distId;
- $this->appearanceId = empty($appearanceId) ? 0 : $appearanceId;
- $this->templateId = empty($templateId) ? 0 : $templateId;
- parent::__construct();
- }
- /*
- * 表单设置
- */
- public function form()
- {
- $variableRow = DistAppearanceVariable::getVariableRow($this->distId,$this->appearanceId,$this->templateId);
- if ($variableRow) {
- $i = 0;
- foreach ($variableRow as $key => $value) {
- $this->hidden('field['.$i.'][id]',$value->id);
- if ($value->variable_type == '1') {
- //文本类型
- $this->text('field['.$i.']['.$value->variable_name.']',$value->variable_name)
- ->default($value->variable_value)
- ->width(12,12)
- ->setLabelClass('d-flex');
- } elseif ($value->variable_type == '2') {
- //长文本类型
- $this->textarea('field['.$i.']['.$value->variable_name.']',$value->variable_name)
- ->default($value->variable_value)
- ->width(12,12)
- ->setLabelClass('d-flex');
- } elseif ($value->variable_type == '3') {
- //json类型
- $this->textarea('field['.$i.']['.$value->variable_name.']',$value->variable_name)
- ->default($value->variable_value)
- ->width(12,12)
- ->setLabelClass('d-flex');
- }
- $i++;
- }
- }
- $this->disableSubmitButton();
- $this->disableResetButton();
- $this->html('<button type="button" class="btn btn-primary">add</button> <button type="button" class="btn btn-success">save</button>');
- }
- // 处理表单提交请求
- public function handle(array $input)
- {
- return $this->response()->success('Processed successfully.')->refresh();
- }
- /**
- * 返回表单数据,如不需要可以删除此方法
- *
- * @return array
- */
- public function default()
- {
- return [];
- }
- }
|