Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails text_field create array of array

I have this code :

<%= form_for :biblio, url: {action: "create"} do |f| %>
 [cut for brievity]
<%= f.text_field :auteur, size: 100, class:"champs_auteur" %>

That creates this html :

<input size="100" class="champs_auteur" name="biblio[auteur]" id="biblio_auteur" type="text">

I'm trying to get the name to be : name="biblio[auteur][1]"

I don't see how.

like image 402
thiebo Avatar asked Aug 22 '26 10:08

thiebo


1 Answers

You can use:

<%= f.text_field :auteur, size: 100, class:"champs_auteur", name: "biblio[auteur][1]" %>
like image 94
Shannon Avatar answered Aug 25 '26 01:08

Shannon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!