Closed TomasValenta closed 8 years ago
Yes you can do it that way & it should be fine.
For some example code, add an ENUM column type to your DB with, say, 3 values. Phreeze Builder will generate a dropdown for that, which you can look at as an example of how to do yours.
Thank you very much @jasonhinkle. It's working!
<select id="genre" name="genre">
<option value=""></option>
<option value="0"<% if (item.get('genre')=='0') { %> selected="selected"<% } %>>Drama</option>
<option value="1"<% if (item.get('genre')=='1') { %> selected="selected"<% } %>>Fantasy</option>
</select>
For 2-10 items is this method fine, but with 300 items? :)
I think with 300 it still probably would be fine, although that is a lot of options for a dropdown. you might look for some fancy component out there to do a better job.
another idea is you can remove the logic within each option tag, that way the dropdown will initially render with no selected value. Then, add some code to page.renderModelView
that sets the selected item there. That way the logic will only run once. But, it's a little more work on your part.
I'd give it a try as-is and see, it just might be fine.
Thank you @jasonhinkle, I'll try it, please give me a time ;)
@TomasValenta Hi Tomas, please read the comments on the bottom here https://github.com/jasonhinkle/phreeze/issues/227
Hello @jasonhinkle,
first thank you very much for your perfect work, it's very useful! I want to ask you for help with bootstrap select. I made this simple DropDownList in *.tpl.php:
but how to pre select the default value? The only working solution is mark one option with "selected" parameter, as is suggested here. But how to do this dynamically?
Something like with the checkboxes?