Search code examples
ruby-on-railssimple-form

Show a hidden field with simple_form


I have a hidden field as such:

<%= f.input :authentication, label: 'Authentication Password', as: :hidden %>

I want to show the hidden field when the admin radio button is clicked:

<%= f.input :account_type , as: :radio_buttons, :checked => 'Student', collection: ['Student', 'Admin'], wrapper: :vertical_radio_and_checkboxes %>

How would I do so?

I have tried using

$('#user_authentication').show();

But this does not work.


Solution

  • Remove as: hidden and use $('#user_authentication').hide(); when DOM is loaded.