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

2 months ago

Takeshi
Member | 568
+
0
-

Hi all,

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

2 months ago

Toanir
Member | 45
+
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)

2 months ago

Takeshi
Member | 568
+
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

2 months ago

Toanir
Member | 45
+
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)

2 months ago

Takeshi
Member | 568
+
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)

2 months ago

Mabar
Member | 268
+
0
-

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

2 months ago

Takeshi
Member | 568
+
-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.

2 months ago

Mabar
Member | 268
+
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/

2 months ago

Šaman
Member | 2427
+
+1
-

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

2 months ago

Toanir
Member | 45
+
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