<?php 
use yii\helpers\Html;
?>
<div id="routeform">
	<div class="col-sm-12 h2">Route Deviations</div>
<?php $form = yii\widgets\ActiveForm::begin(['id' => 'route-form', 	'enableAjaxValidation' => true]) ?>

<?= $form->field($model, 'comments')->TextArea(['placeholder' => 'Please describe reason why the prodived route was not used.'])->label(false) ?>
<?= $form->field($model, 'routetaken')->TextArea(['placeholder' => 'Please describe route taken instead.'])->label(false) ?>

    
    <div class="form-group">
        <?= Html::submitButton('Save', ['class' => 'btn btn-primary']) ?>
    </div>

<?php yii\widgets\ActiveForm::end() ?>
</div>
<script>

	$('form').on('submit', function(e) {
		
		e.preventDefault();
		data = $(this).serialize();
		$.ajax({
			url: '/activities/routedeviation',
			type:'POST',
			data: data
		}).done(function(result) {
			result = JSON.parse(result);
			if (result.result == 200) {
				this.modal
			}
			$('#routeform').html(result.message);
		})
	})
</script>