This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Troiscent
Troiscent

Hello,

I have a model with a dropdown field called "note", with the following options :

  • Excellent
  • Good
  • Average
  • Bad
  • Very bad

In my backend listing, I would like to add a filter based on the note. I defined a config_filter.yaml file as follow :

scopes:
    categories:
        label: Note
        conditions: note in (:filtered)
        options: ??????

I need to replace the ????? with something that will display the options defined in my dropdown, but I don't know how to do that. The documentation have no example about how to retrieve the dropdown options to display them as a filter.

Thanks for your help.

virgo9793756674
virgo9793756674
options:
            pending: Pending
            active: Active
            closed: Closed

Last updated

mjauvin
mjauvin

@Troiscent do you mean you want to reuse the Model's note field options defined in the model?

mjauvin
mjauvin

The documentation says this:

... can specify an array or a method name in the modelClass model.

e.g.:

scopes:
    categories:
        label: Note
        conditions: note in (:filtered)
        modelClass: Author\Plugin\Models\YourModelWithNoteField
        options: getNoteOptions

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.