jcadima
8/22/2017 - 5:35 AM

/views/task/create.blade.php

/views/task/create.blade.php


@extends('layout')

@section('content')

@include('includes.errors') 

<form id="task_form" action="{{ route('task.store') }}" method="POST">
    {{ csrf_field() }}

    <div class="col-md-8">
    	<label>Create new task <span class="glyphicon glyphicon-menu-right" aria-hidden="true"></span></label>
		<div class="form-group">
			<textarea class="form-control" rows="5" id="task" name="task"></textarea>
		</div>
	</div>

	<div class="col-md-4">
		<div class="form-group">
			<label>Assign to Project <span class="glyphicon glyphicon-pushpin" aria-hidden="true"></span></label>
			<select name="project_id" class="selectpicker" data-style="btn-primary" style="width:100%;">
				@foreach( $projects as $project )
					<option value="{{ $project->id }}">{{ $project->project_name }}</option>
				 @endforeach
			</select>
		</div>
	
		<div class="form-group">
			<label>Select Priority <span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span></label>
			<select name="priority" class="selectpicker" data-style="btn-info" style="width:100%;">
			  <option value="0">Normal</option>
			  <option value="1">High</option>
			</select>
		</div>
	</div>

	<div class="btn-group">
		<input class="btn btn-primary" type="submit" value="Submit" onclick="return validateForm()">
		<a class="btn btn-default" href="{{ redirect()->getUrlGenerator()->previous() }}">Go Back</a>
	</div>

</form>

@stop

<script>
function validateForm() {
	console.log("VALIDATE FORM CLICKED") ;
	var task = document.forms["task_form"]["task"].value;

	if ( !task.length ) {
		swal("Enter Task Description", "" , "warning") ;
		document.getElementById("task").focus();
		return false;
	}
}

</script>