How to filter the content of a select box in the editor form?

How to filter the content of a select box in the editor form?

huba_sbfhuba_sbf Posts: 16Questions: 6Answers: 1

Hello,

I would like to know if there is a way to actually filter the content being loaded into a "select box" in the editor form.
Let's have a look at this example: https://editor.datatables.net/examples/simple/join.html.
The sites, db table has the "id" and "name" fields.
Question: Is it possible to only load the city names starting with "L" in the "Sites" select box? If yes, could you please tell me how to do it? My guess is adding a "where" clause on the "name" field, but for some reason I have only managed to filter the content of my table, not the content of the select box.

Thanks a lot and cheers for a great product!

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 64,951Questions: 1Answers: 10,758 Site admin
    Answer ✓

    Hi,

    Yes indeed this is possible. The Field->options() method has an optional fourth parameter which is the WHERE condition to be applied. Documentation for it is available here.

    Regards,
    Allan

  • huba_sbfhuba_sbf Posts: 16Questions: 6Answers: 1

    Thanks a lot! It worked like a charm.

This discussion has been closed.