<style>
    #TiType_validity_mode .radio {
	display: block !important;
    }

    #TiType_validity_days {
        width: 150px !important;
    }

</style>

<?php
/* @var $this CityController */
/* @var $model City */
/* @var $form CActiveForm */
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
	    'id' => 'ti-type-form',
	    'enableAjaxValidation' => false,
	));

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

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


echo $form->radioButtonListControlGroup($model, 'validity_mode', TiType::getValidityModeOptions(), array('onchange' => 'validityModeChange(this.value);'));

echo "<br/>";
echo "<div id='validity_days_div'>";


echo $form->textFieldControlGroup($model, 'validity_days', array('size' => 60,'append' => 'Day(s)'));
//echo '<span id="days_span">'."    ".Yii::t("default", "Day(s)") .'</span>';

echo "</div>";


if ($model->isNewRecord) {
    $model->status = 'Active';
}
echo $form->radioButtonListControlGroup($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 type="text/javascript">
        var validity_mode_value ='<?php echo (($model->validity_days != null && $model->validity_days != '') || ($model->validity_mode == 'Based on Validity Days')) ? 'show' : 'hide' ?>';
	$(document).ready(function(){	    
	    if(validity_mode_value == 'show')
		$("#validity_days_div").show();
	    else
		$("#validity_days_div").hide();

	    $("#days_span").insertAfter($("#TiType_validity_days"));
	});

	function validityModeChange(value){
	if(value == 'Based on Validity Days')
	    $("#validity_days_div").show();
	else
	    $("#validity_days_div").hide();
	}

</script>
