How to add a datalist to an input form
- asinkan
- Member | 38
Hi,
I have a form in my presenter
how can I add there a datalist? Like in HTML:
The question is: How to add attribute list=“browsers” to
my input form. I can do other things in default.latte
Thx very much
++++++++++++++++++++++++++++++++++++++++++++++
OK I found nice solution. Everything is in the presenter
Do not forget to add
Last edited by asinkan (2018-11-27 23:17)
- Martin
- Member | 171
Simpliest way, usable to standard renderer:
Using:
Result:
You can also add extension method addDataList to TextBox or method to its
descendant.
Or define class TextBoxWithDatalist, but one DataList belongs to one TextBox in
this case, which could not be right way.
Or use more complex solution by deep Nette OOP and DI, but they are more
desirable ones to do it then me.
Last edited by Martin (2018-01-25 22:06)
- David Matějka
- Moderator | 6445
@Martin the way you are building the html is insecure and may result
in xss. you should at least use Nette\Utils\Html
- Martin
- Member | 171
David Matějka wrote:
@Martin the way you are building the html is insecure and may result in xss. you should at least use
Nette\Utils\Html
Thank you. I am sorry, I din not use Nette last 6 years. Do you mean to check $value only, or full result, or another way? I will repaire code above.
- Martin
- Member | 171
Thanks, I repaired a code. Hovewer, cutting off is not working
probably in <?php code ?> here, then I removed wrong code part. I will
try it when I am near my computer.
…
After adding one parenthesis the code is working. Thank you for the correction.
Last edited by Martin (2018-01-25 22:35)