<div class="row">
    <div class="col-md-6 col-md-offset-3"> 
       
        <div class="form-group <?php echo e($errors->has('board_id') ? ' has-error' : ''); ?>">
            <label class="control-label">Board <span class="text-danger">*</span></label>
            <?php echo Form::select('board_id',[''=>'-- Select Subject --']+App\Model\Board::all()->pluck('name','id')->toArray() ,null, ['class' => 'form-control js-example-basic-multiple','id'=>'board_id','required'=>'required']); ?>

            <span class="help-block" id="error_category_id"><strong><?php echo e($errors->first('board_id')); ?></strong></span>
        </div>

        <div class="form-group <?php echo e($errors->has('medium_id') ? ' has-error' : ''); ?>">
            <label class="control-label">Medium <span class="text-danger">*</span></label>
            <?php echo Form::select('medium_id',[''=>'-- Select Medium --']+App\Model\Medium::all()->pluck('name','id')->toArray() ,null, ['class' => 'form-control js-example-basic-multiple','id'=>'medium_id','required'=>'required']); ?>

            <span class="help-block" id="error_category_id"><strong><?php echo e($errors->first('medium_id')); ?></strong></span>
        </div>

        <div class="form-group <?php echo e($errors->has('standard_id') ? ' has-error' : ''); ?>">
            <label class="control-label">Standard <span class="text-danger">*</span></label>
            <?php echo Form::select('standard_id',[''=>'-- Select Standard --']+App\Model\Standard::all()->pluck('name','id')->toArray() ,null, ['class' => 'form-control js-example-basic-multiple','id'=>'standard_id','required'=>'required']); ?>

            <span class="help-block" id="error_category_id"><strong><?php echo e($errors->first('standard_id')); ?></strong></span>
        </div>

        <div class="form-group <?php echo e($errors->has('name') ? ' has-error' : ''); ?>">
            <label class="control-label">Name <span class="text-danger">*</span></label>
            <?php echo Form::text('name',null, ['class' => 'form-control','required'=>'required']); ?>

            <span class="help-block" id="error_name"><strong><?php echo e($errors->first('name')); ?></strong></span>
        </div>
	   
       
        
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $('.js-example-basic-multiple').select2();
    });
</script>
<?php $__env->startSection('js'); ?>
<script>
    $(document).ready(function() {
    $('#medium_id').change(function() {
        var mediumId = $(this).val();
        $('#standard_id').empty(); // Clear the subjects dropdown

        if (mediumId) {
            $.ajax({
                url: "<?php echo e(url('admin/getstandard')); ?>/" + mediumId, // Update with your route
                type: 'GET',
                success: function(data) {
                    // Populate subjects dropdown
                    $('#standard_id').append($('<option value="">-- Select Standard --</option>'))
                    $.each(data, function(key, value) {
                        $('#standard_id').append($('<option></option>').attr('value', key).text(value));
                    });
                },
                error: function() {
                    alert('Could not fetch standard. Please try again later.');
                }
            });
        } else {
            $('#standard_id').empty(); // If no standard selected, clear subjects
        }
    });
});
</script>
<?php $__env->stopSection(); ?> 



