Rafal
Rafal

Reputation: 11

Form field - username value is not being shown

I would like to use forms in Ruby on Rails and add current_user.username field as autocomplete. Currently I use the code, which does show the username, but after submitting the form, username does not go to the database and is not being presented in the final version of the form.

'''

<%= f.input :collectionnumber, :input_html => { :value => current_user.username }, label: false, disabled: true %>

'''

Upvotes: 1

Views: 41

Answers (1)

Vishal Jain
Vishal Jain

Reputation: 501

<%= f.input :collectionnumber, :input_html => { :value => current_user.username }, label: false, readonly: true %>

Form doesn't submit disable fields, You can either use readonly: true if you don't want user to edit it.

Upvotes: 1

Related Questions