'Hide default value in form Ruby
I have a form and when I set a value, the value is displayed in the field, how to not display the value but keep the existing values when submitting the form:
Here is my form :
= form_with model: resource, local: true, url: author_path(resource) do |f|
.form-group
= f.label :books
= f.text_field :list_books, multiple: true
.form-group
= f.label :title
= f.text_field :list_books, multiple: true
.form-group:
= f.submit 'Save'
For example, if in a first time I set :
books
to fiction
and title
to planet of apes
When I will go back to edit this resource, I will see in both fields fiction planet of apes
because my field list_books
is ["fiction", "planet of apes"]
I can't go with an empty value in my field because I want to keep the existing values on submit
For example if I submit another time the form with a books
: "scary"
and a title
: "scream"
I would like to have ["fiction", "planet of apes", "scary", "scream"]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|