<?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'distributer-form',
    'enableAjaxValidation' => false,
    'enableClientValidation' => false,
));
?>
<div class="tab-content">
    <div class="tab-pane active">
        <ul class="clearfix form-ul material">
            <?php echo $form->hiddenField($model, 'id'); ?>
            <li class="col-sm-4">
                <?php echo $form->textField($model, 'distributer_name', array('data-label' => 'Distributor Name <span style="color:red">*</span>', 'data-validation' => 'required')); ?>
            </li> 
            <li class="col-sm-4">
                <?php echo $form->dropdownList($model, 'region_id',MasRegion::getRegions() ,array('data-label' => 'Area Price <span style="color:red">*</span>', 'data-validation' => 'required','empty' => 'Select')); ?>
            </li> 
            <li class="col-sm-4">
                <?php echo $form->dropdownList($model, 'isActive', array('Y' => 'Yes', 'N' => 'No'), array('data-label' => 'Is Active')); ?>
            </li>
        </ul>
    </div>
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-default" id="distributer_close" data-dismiss="modal">Close</button>
    <?php
    $url = Yii::app()->createUrl('distributer/Save');
    echo CHtml::ajaxSubmitButton('Save', $url, array(
        'dataType' => 'json',
        'type' => 'post',
        'success' => 'function(data) {
            $("#loader").hide();
                if(data.status=="success"){  
                    t8.success("Brand Saved Successfully!");
                    $("#distributer_close").click();
                    reloadTable("#tbl_distributer_details");
                } else { 
                    $("#distributer-form .distributer-save-btn").prop("disabled", false);                      
                    $("#distributer-form .distributer-save-btn").addClass("btn-theme").removeClass("btn_loading"); 
                    $.each(data, function(key, val) {
                        t8.error(""+val+""); 
                    }); 
                } 
        }',
        'beforeSend' => 'function(){ 
            $("#loader").show();
            $(".toast8-error").hide();
            $("#distributer-form .distributer-save-btn").prop("disabled", true);                      
            $("#distributer-form .distributer-save-btn").addClass("btn_loading").removeClass("btn-theme"); 

        }'
    ), array('id' => 'mybtn' . rand(), 'class' => 'distributer-save-btn btn btn-theme'));
    ?>
</div>
<?php $this->endWidget(); ?>