

<?php $__env->startSection('content'); ?>

    <div class="card">

        <div class="card-header bg-primary text-white">
            
            <h5  class="my-1 float-left">เพิ่ม บ้านเลขที่ ใหม่</h5>

            <div class="btn-group btn-group-sm float-right" role="group">
                <a href="<?php echo e(route('homes.home.index')); ?>" class="btn btn-primary" title="แสดง บ้านเลขที่ ทั้งหมด">
                    <i class=" fas fa-fw fa-th-list" aria-hidden="true"></i>
                </a>
            </div>

        </div>

        <div class="card-body">
        
            <?php if($errors->any()): ?>
                <ul class="alert alert-danger">
                    <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <li><?php echo e($error); ?></li>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </ul>
            <?php endif; ?>

            <form method="POST" action="<?php echo e(route('homes.home.store')); ?>" accept-charset="UTF-8" id="create_home_form" name="create_home_form" class="form-horizontal">
            <?php echo e(csrf_field()); ?>

            <?php echo $__env->make('homes.form', [
                                        'home' => null,
                                      ], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

                <div class="form-group">                     
						<div align="center">
						  <button class="btn btn-primary" type="submit">
						  <i class="fas fa-fw fa-save"></i> บันทึก</button>
						  <button class="btn btn-light" type="reset" onclick="history.back();"> 
						  <i class="fas fa-fw fa-redo" aria-hidden="true"></i> ยกเลิก</button>
						</div>
                </div>

            </form>

        </div>
    </div>

<?php $__env->stopSection(); ?>



<?php $__env->startSection('script'); ?>

    <script>
        function get_tambons(  amphurs_id  )
{	 
	 $.ajax({ 
			type: 'POST', 
			url: "<?php echo e(route('tambons.tambon.get_tambon_by_amphur',0)); ?>"+amphurs_id, 
			data: {_token:'<?php echo e(csrf_token()); ?>' }, 
			dataType: 'text',
			success: function (data) 
				 {				
				   $('#tambons_id' ).html('');
					$('#tambons_id' ).append(data);
				 }
			})
}

function get_moobans(  tambons_id )
{	 
	 $.ajax({ 
			type: 'POST', 
			url: "<?php echo e(route('moobans.mooban.get_mooban_by_tambon',0)); ?>"+tambons_id , 
			data: {_token:'<?php echo e(csrf_token()); ?>'}, 
			dataType: 'text',
			success: function (data) 
				 {				
					$('#moobans_id' ).html('');
					$('#moobans_id' ).append(data);
				 }
			})
}

function get_homes(  moobans_id )
{	 
	 $.ajax({ 
			type: 'POST', 
			url: "<?php echo e(route('homes.home.get_home_by_mooban',0)); ?>"+moobans_id , 
			data: {_token:'<?php echo e(csrf_token()); ?>'}, 
			dataType: 'text',
			success: function (data) 
				 {                   
					 $('#homes_id' ).html('');
					 $('#homes_id' ).append(data);
				 }
			})
}


        </script>
<script>
document.addEventListener('DOMContentLoaded', function() {
  // เลือก input ทั้งหมดใน form
  const inputs = document.querySelectorAll('form input');

  inputs.forEach(function(input) {
    input.addEventListener('keydown', function(event) {
      if (event.key === 'Enter') {
        event.preventDefault(); // ป้องกันการ submit
        return false;
      }
    });
  });
});
</script>
<script>
    (() => {
  'use strict'

  // Fetch all the forms we want to apply custom Bootstrap validation styles to
  const forms = document.querySelectorAll('.needs-validation')

  // Loop over them and prevent submission
  Array.from(forms).forEach(form => {
    form.addEventListener('submit', event => {
      if (!form.checkValidity()) {
        event.preventDefault()
        event.stopPropagation()
      }

      form.classList.add('was-validated')
    }, false)
  })
})()
</script>
<?php $__env->stopSection(); ?>


<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\xampp7.4R1\htdocs\disk8\election\source\resources\views/homes/create.blade.php ENDPATH**/ ?>