Set Forme Field With Value Under Condition

hello yii frindes

I hope you can help me

I built a form (Activity._form) which can be accessed in 3 ways.

  1. main calender

echo CHtml::button('create', array('onclick' => 'js:document.location.href="index.php?r=activity/create&time_code='.$timecode.'"'));

the $timecode Represents time and day

  1. Updating

using exsisting $model

  1. Creation - with no $timecode that sent

the _form is


<div class="row">

		

		<?php echo $form->textField($model,'timetable_code',array('id'=>'timecode','tabindex'=>3,'value'=>$_GET['time_code'], 'readonly' => 'true')); ?>

		<?php echo $form->error($model,'timetable_code'); ?>

	</div>

It works great on a 1 but when I try the others it’s not because missing variable $time_code

Is there a way to use the same form in three cases, or should I create a new form for each of them

?

You mean something like


'value' => isset($_GET['time_code']) ? $_GET['time_code'] : ''

?

You can use getParam for that,


'value' => Yii::app()->request->getParam('time_code', '')

lol, turns out it can save a couple of symbols :D

YES!!!

thenks!!! :D