rainlab / translate-plugin

Enables multi-lingual sites
Other
125 stars 88 forks source link

Translate dynamic dropdown options in repeater #710

Closed ssi-com-pl closed 1 year ago

ssi-com-pl commented 1 year ago

Hi! I use dropdown field in repeater to create a list of places. Places are added in the backend. How to display translated place names on the frontend?

        places:
            label: 'Places nearby'
            style: accordion
            span: left
            type: repeater
            tab: 'Places nearby'
            form:
                fields:
                    place:
                        label: Place
                        span: auto
                        showSearch: true
                        type: dropdown
                    distance:
                        label: 'Distance (m)'
                        span: auto
                        type: text
                    place_address:
                        label: 'Address'
                        span: full
                        type: text
    public function getPlaceOptions(){
        return Place::orderBy('name')->lists('name','name');
    }

image image image image

daftspunk commented 1 year ago

This function does not apply translation

return Place::orderBy('name')->lists('name','name');

It may need to be something like

return Place::orderBy('name')->get()->lists('name','name');