在Fields.yaml文件代码为:
category:
label: Category
nameFrom: category_name
descriptionFrom: description
span: auto
type: relation
我的控制器代码是:
public $belongsTo = [
'category' => [
'Ashish\Taeq\Models\RecipeCategory',
'conditions' => 'status = 1'
],
我需要设置默认类别下拉菜单,例如“请选择类别”。
答案 0 :(得分:4)
请使用
On Fields.yaml上的
emptyOption: " "
category:
label: Category
nameFrom: category_name
descriptionFrom: description
span: auto
type: relation
emptyOption: " "
或请点击以下链接:https://octobercms.com/forum/post/filtering-form-fields-with-dependson-problem