<%=
  breadcrumbs(
    { 'Providers' => providers_path },
    { @provider.name => provider_path(@provider) },
    { 'Provided Attributes' => url_for([@provider, :provided_attributes]) },
    'Invite New User'
  )
%>

<%= page_header(@provider.name, 'Invite New User') %>

<%= form_for([@provider, @invitation]) do |f| -%>
  <%= field_block do -%>
    <%= f.label(:name) %>
    <%= f.text_field(:name) %>
  <%- end -%>

  <%= field_block do -%>
    <%= f.label(:mail, 'Email Address') %>
    <%= f.text_field(:mail) %>
  <%- end -%>

  <div class="line-of-buttons">
    <%- if permitted?("providers:#{@provider.name}:invitations:create") -%>
      <%= button_tag(type: 'submit', class: 'large green icon') do -%>
        <%= icon_tag('checkmark') %>
        Send Invitation
      <%- end -%>
    <%- end -%>

    <%= button_link_to(provider_provided_attributes_path(@provider), class: 'large icon') do -%>
      <%= icon_tag('cancel') %>
      Cancel
    <%- end -%>
  </div>
<%- end -%>

<%=
  breadcrumbs(
    { 'Providers' => providers_path },
    { @provider.name => provider_path(@provider) },
    { 'Provided Attributes' => url_for([@provider, :provided_attributes]) },
    'Invite New User'
  )
%>

<%= page_header(@provider.name, 'Invite New User') %>

<%= form_for([@provider, @invitation]) do |f| -%>
  <%= field_block do -%>
    <%= f.label(:name) %>
    <%= f.text_field(:name) %>
  <%- end -%>

  <%= field_block do -%>
    <%= f.label(:mail, 'Email Address') %>
    <%= f.text_field(:mail) %>
  <%- end -%>

  <div class="line-of-buttons">
    <%- if permitted?("providers:#{@provider.name}:invitations:create") -%>
      <%= button_tag(type: 'submit', class: 'large green icon') do -%>
        <%= icon_tag('checkmark') %>
        Send Invitation
      <%- end -%>
    <%- end -%>

    <%= button_link_to(provider_provided_attributes_path(@provider), class: 'large icon') do -%>
      <%= icon_tag('cancel') %>
      Cancel
    <%- end -%>
  </div>

  <%= error_messages_tag %>
<%- end -%>

<%= validate_form('#new_invitation', :invitation) do -%>
  <%= validate_field(:name, empty: 'Please enter the users full name') %>
  <%= validate_field(:mail, email: 'Please enter a valid email address') %>
<%- end -%>

Validate invitation creation in UI
Validate invitation creation in UI

Ensure administrators are prompted if invalid data is entered to
invitation form instead of previous exception.

Closes #28.
