Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize Devise_invitable generated forms?

The form path is user/invitations/invitations/edit.html.erb and new.html.erb

Edit.html.erb

    <h2><%= t 'devise.invitations.edit.header' %></h2>
    <%= form_for resource, :as => resource_name, :url => invitation_path(resource_name),  :html => { :method => :put } do |f| %>
    <%= devise_error_messages! %>
    <%= f.hidden_field :invitation_token %>

    <p><%= f.label :username %><br />
    <%= f.text_field :username %></p>

    <p><%= f.label :password %><br />
    <%= f.password_field :password %></p>

    <p><%= f.label :password_confirmation %><br />
    <%= f.password_field :password_confirmation %></p>

    <p><%= f.submit t("devise.invitations.edit.submit_button") %></p>
    <% end %>

I added the following by myself in the edit.html.erb but the form isn't showing up the fields

    <p><%= f.label :username %><br />
    <%= f.text_field :username %></p>

Please let me know how to deal with this. And customize forms for devise_invitable

like image 376
Amandeep Singh Bhamra Avatar asked Jan 30 '26 00:01

Amandeep Singh Bhamra


2 Answers

I Generated views again by following command:

    rails generate devise_invitable:views users

and then found that the nesting done users/invitations/invitaions/edit.html.erb was wrong.

It should be like views/users/invitations/edit.html.erb

This solved my problem and now i am able to customize devise_invitable form.

like image 196
Amandeep Singh Bhamra Avatar answered Feb 01 '26 16:02

Amandeep Singh Bhamra


Your replacement form should go here

app/views/devise/invitations/edit.html.erb
like image 39
Edward Avatar answered Feb 01 '26 14:02

Edward



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!