How to create form with editable ->addSelect(“category”, “Category:”)?

Takeshi
Member | 596
+
0
-

Hi all,

how can I create in form an editable >addSelect(“category”, “Category:”)?
Thank you.

Toanir
Member | 57
+
0
-

The addSelect method creates instance of SelectBox. You should pass the selectable items as a third parameter in an associative array:

$form->addSelect("drink", "Favourite morning drink:", [
  'tea' => 'Tea.',
  'coffee' => 'COFFEEEEE!!!! !! !!!! !',
]);

Last edited by Toanir (2020-03-25 11:33)

Takeshi
Member | 596
+
0
-

Toanir wrote:

The addSelect method creates instance of SelectBox. You should pass the selectable items as a third parameter in an associative array:

$form->addSelect("drink", "Favourite morning drink:", [
  'tea' => 'Tea.',
  'coffee' => 'COFFEEEEE!!!! !! !!!! !',
]);

OK, so please give me an example … your code doesnt contain an editable item

Toanir
Member | 57
+
0
-

I must have misunderstood your question so let's go back to the terminology. What is an ‘editable’? How should it behave?

Last edited by Toanir (2020-03-26 15:55)

Takeshi
Member | 596
+
0
-

Toanir wrote:

I must have misunderstood your question so let's go back to the terminology. What is an ‘editable’? How should it behave?

At first, I am sorry for my english :-)

1. When I/we ceate a ->addSelect(), we put inside some data, array … and when it is rendered, I can choose one of them, but I can not write/type another text.

Last edited by Takeshi (2020-03-26 16:04)

Marek Bartoš
Nette Blogger | 1165
+
0
-

That's text input with datalist, not selectbox
https://caniuse.com/#…

Takeshi
Member | 596
+
-1
-

Mabar wrote:

That's text input with datalist, not selectbox
https://caniuse.com/#…

Thank you for that,

can you give me an example? A cant reat it from your link. Thanks.

Marek Bartoš
Nette Blogger | 1165
+
0
-

Features at caniuse.com have tab “resources” where you can find everything you need, e.g. https://hacks.mozilla.org/…html5-forms/
Just search for input with datalist, you may also want some JS implementation as well, e.g. http://projects.sergiodinislopes.pt/flexdatalist/

Šaman
Member | 2634
+
+1
-

Takeshi: You are from Slovakia? Why dont you ask in czech forum, slovak language is fine.

Toanir
Member | 57
+
0
-

Wow, I've been living under a rock… I had no idea about datalist.

If I were to implement the functionality in question, up until now I'd use something like select2 with tagging. I'll have to look into the datalist element :P