ProductsController::form 方法和 CategoriesController::form 方法中的类目 select 实现不同?
CategoriesController::form
$form->select('parent_id', '父类目')->ajax('/admin/api/categories');
ProductsController::form
$form->select('category_id', '类目') ->options(function ($id) { $category = Category::find($id); if ($category) { return [$category->id => $category->full_name]; } })->ajax('/admin/api/categories?is_directory=0');
主要疑问是options那里,我尝试把
ProductsController::form
中的options
去掉,也能正常新增、编辑商品啊,这里加options
的意义是什么?
推荐文章: