1

How do I pre-fill a form field in Simple Form? I tried setting the default value, but still it wouldn't show up when the form loaded:

= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f|
  = f.error_notification
  .form-inputs
    = f.input :code_entered, label: 'Checklist Code', value: params[:q], input_html: {id: 'sign_up_code' }
  .form-actions
    = f.button :submit, "Sign up"

Setting params[:q] as a placeholder value works, however.

1 Answers1

9
= f.input :code_entered, label: 'Checklist Code', input_html: {id: 'sign_up_code', value: params[:q] }
Sergey Sokolov
  • 994
  • 7
  • 6