<form id="permission-template-form" method="post" action="<%= ApplicationController.root_context -%>/permission_templates/<%= form_action %>">
  <% if form_action == 'edit' %>
    <input type="hidden" name="id" value="<%= @permission_template.id -%>">
  <% end %>
  <fieldset>
    <div class="modal-head">
      <h2><%= message("permission_template.#{message_title}") -%></h2>
    </div>
    <div class="modal-body">
      <div class="modal-error"/>
      <div class="modal-field">
        <label for="name"><%= h message('name') -%> <em class="mandatory">*</em></label>
        <input id="name" name="name" type="text" maxlength="256" value="<%= @permission_template ? @permission_template.name : '' -%>" autofocus="autofocus" style="width: 330px;"/>
      </div>
      <div class="modal-field">
        <label for="description"><%= h message('description') -%></label>
        <textarea id="description" name="description" maxlength="4000" rows="10" style="width: 330px;"><%= @permission_template ? @permission_template.description : '' -%></textarea>
      </div>
      <div class="modal-field">
        <label for="keyPattern"><%= h message('permission_template.key_pattern') -%></label>
        <input id="keyPattern" name="pattern" type="text" maxlength="500" value="<%= @permission_template ? @permission_template.keyPattern : '' -%>" style="width: 330px;"/>
      </div>
    </div>
    <div class="modal-foot">
      <input type="submit" value="<%= h message("permission_template.#{message_submit}") -%>" id="submit-permission-template-<%= form_action %>"/>
      <a href="#" onclick="return closeModalWindow()" id="cancel-<%= form_action %>-template"><%= h message('cancel') -%></a>
    </div>
  </fieldset>
</form>

<script>
  $j("#permission-template-form").modalForm({
    success: function (data) {
      window.location.reload();
    }
  });
</script>

