How to add default value in drodown in october cms?

- 1 answer

Ad

enter image description here

On Fields.yaml file code is :

category:
        label: Category
        nameFrom: category_name
        descriptionFrom: description
        span: auto
        type: relation

My controller code is :

public $belongsTo = [
                    'category' => [
                         'Ashish\Taeq\Models\RecipeCategory',
                      'conditions' => 'status = 1'
                      ],

I need to set default category drop-down like "Please select category".

Ad

Answer

Ad

Please Use

emptyOption: " "

on On Fields.yaml

   category:
            label: Category
            nameFrom: category_name
            descriptionFrom: description
            span: auto
            type: relation
            emptyOption: " "

Or Please follow below link : https://octobercms.com/forum/post/filtering-form-fields-with-dependson-problem

Ad
source: stackoverflow.com
Ad