Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

[SOLVED] Add class to selectStatic

Hey community!

Is there a posiibility to add a class to the volt-syntax of a select-box? In the following example I want the class "form-control" to be added to the select tag.

{{ selectStatic("searchtype", ["title": "Titel", "actors": "Schauspieler"], ["class":"form-control"]) }}

greetings Eike



3.7k
Accepted
answer

I think the documentation Volt syntax for this is missing the open and close brackets. Try

{{ selectStatic(["searchtype", ["title": "Titel", "actors": "Schauspieler"], "class":"form-control"]) }}

It looks like Volt is using json syntax, so when you see an array() in the $this-tag implementation, you need to enclose the params in [ ] to make it a javascript array.



8.4k

Thanks! This works! Sometimes it is so easy :)