配置表单字段,生成添加和编辑表单的输入框; 不同类型的值,需要配置不同的字段;
#project\app\admin\controller\Category.php
namespace app\admin\controller;
use easyadmin\app\columns\form\FormAutocomplete;
use easyadmin\app\columns\form\FormCheckbox;
use easyadmin\app\columns\form\FormCurrency;
use easyadmin\app\columns\form\FormDateTime;
use easyadmin\app\columns\form\FormDateTimeRange;
use easyadmin\app\columns\form\FormEditor;
use easyadmin\app\columns\form\FormHidden;
use easyadmin\app\columns\form\FormNumber;
use easyadmin\app\columns\form\FormRadio;
use easyadmin\app\columns\form\FormSelect;
use easyadmin\app\columns\form\FormSwitch;
use easyadmin\app\columns\form\FormText;
use easyadmin\app\columns\form\FormTextarea;
use easyadmin\app\columns\form\FormUpload;
use easyadmin\app\libs\PageForm;
class Category extends \easyadmin\controller\Admin
{
/**
* 配置表单
* @param PageForm $page
*/
protected function configFormField(PageForm $page)
{
$page
->addField('field','字段名称',FormAutocomplete::class,[
// options 选项
])
->addField('field','字段名称',FormCheckbox::class,[
// options 选项
])
->addField('field','字段名称',FormCurrency::class,[
// options 选项
])
->addField('field','字段名称',FormDateTime::class,[
// options 选项
])
->addField('field','字段名称',FormDateTimeRange::class,[
// options 选项
])
->addField('field','字段名称',FormEditor::class,[
// options 选项
])
->addField('field','字段名称',FormHidden::class,[
// options 选项
])
->addField('field','字段名称',FormNumber::class,[
// options 选项
])
->addField('field','字段名称',FormRadio::class,[
// options 选项
])
->addField('field','字段名称',FormSelect::class,[
// options 选项
])
->addField('field','字段名称',FormSwitch::class,[
// options 选项
])
->addField('field','字段名称',FormText::class,[
// options 选项
])
->addField('field','字段名称',FormTextarea::class,[
// options 选项
])
->addField('field','字段名称',FormUpload::class,[
// options 选项
]);
}
}
- 1. 不同的字段,只是在 options 选项上的不同;
- 2.
configFormField
方法表示配置表单;详见表单配置