<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
	  xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3"
      layout:decorator="layout/mainLayout">
      
      <head>
        <title>Roles - New</title>
    </head>
    <body>
        
    	<div layout:fragment="content">
	        
              <div class="box box-warning">
                <div class="box-header with-border">
                  <h3 class="box-title">Create New Role</h3>
                </div><!-- /.box-header -->
                <div class="box-body">
                  <form role="form" th:action="@{/roles}" th:object="${role}" method="post">
                  	<p th:if="${#fields.hasErrors('global')}" th:errors="*{global}" th:class="text-red">Incorrect data</p>
                    <!-- text input -->
                    <div class="form-group" th:classappend="${#fields.hasErrors('name')}? 'has-error'">
                      <label>Name</label>
                      <input type="text" class="form-control" name="name" th:field="*{name}" placeholder="Enter Role Name"/>
                      <p th:if="${#fields.hasErrors('name')}" th:errors="*{name}" th:class="text-red">Incorrect data</p>
                    </div>
                    
                    <!-- textarea -->
                    <div class="form-group" th:classappend="${#fields.hasErrors('description')}? 'has-error'">
                      <label>Description</label>
                      <textarea class="form-control" rows="3" name="description" th:field="*{description}" placeholder="Enter Role Description"></textarea>
                      <p th:if="${#fields.hasErrors('description')}" th:errors="*{description}" th:class="text-red">Incorrect data</p>
                    </div>
					
					<div class="form-group">
						<label>Permissions</label>
						<div>
						  <p th:each="permission,rowStat : ${permissionsList}">
						    <input type="checkbox" th:field="*{permissions[__${rowStat.index}__].id}" th:value="${permission.id}" />
						    <label th:text="${permission.name}">Permission</label>
						  </p>
						</div>
						
    				</div>
    				
					<div class="box-footer">
	                    <button type="submit" class="btn btn-primary">Submit</button>
	                </div>
                  </form>
                </div><!-- /.box-body -->
              </div><!-- /.box -->
    	</div>
    	
    </body>
    
</html>