<?php
/* @var $this PersonTypeController */
/* @var $model PersonType */
/* @var $form CActiveForm */
?>

<?php
$form = $this->beginWidget('bootstrap.widgets.FTbActiveForm', array(
            'id' => 'person-type-form',
            'enableAjaxValidation' => false,
        ));

$this->widget('bootstrap.widgets.TbAlert');


echo $form->textFieldRow($model, 'name', array('size' => 60, 'maxlength' => 255));

if ($model->isNewRecord)
{
    $model->is_ldap = 1;
     $model->status = 'Active';
}

echo $form->radioButtonListInlineRow($model, 'is_ldap', array('1' => Yii::t('default', 'Yes'), '0' => Yii::t('default', 'No')), array(
    'onchange' => 'manage_equivalent_ldap_type_visibility()',    
));

if((!$model->isNewRecord)&&($model->is_ldap ==0))
{
echo $form->textFieldRow($model, 'equivalent_ldap_type', array('size' => 60, 'maxlength' => 255,'disabled'=>'disabled'));

}else{

echo $form->textFieldRow($model, 'equivalent_ldap_type', array('size' => 60, 'maxlength' => 255));
}

echo $form->radioButtonListInlineRow($model, 'status', array('Active' => Yii::t('default', 'Active'), 'Inactive' => Yii::t('default', 'Inactive'))); 
?>

<div class="actions">
    <?php echo CHtml::submitButton(Yii::t('default', 'Save'), array('class' => 'btn primary')); ?>
    &ensp;
    <?php echo CHtml::link(Yii::t('default', 'Cancel'), array('index'), array('class' => 'btn primary')); ?>
</div>

<?php $this->endWidget(); ?>

<script language="javascript" type="text/javascript">
    // this function will toggle the price input field if the program changed to free, and will display it again if the program changed to not free
    function manage_equivalent_ldap_type_visibility(){
        if($("#PersonType_is_ldap_1").attr('checked')){
            $('#PersonType_equivalent_ldap_type').attr('disabled','disabled');//.val('');
        }
        else{
            $('#PersonType_equivalent_ldap_type').removeAttr('disabled');
        }
    }
</script>