saegeek
(Abdallah)
January 25, 2010, 5:51pm
1
Hi @ all !
I’m trying to create a form that collect tabular input but I have a problem with ActiveLabels.
I’m using the following at a loop and it works well :
echo CHtml::activeLabelEx($model,'['.$i.']url');
echo CHtml::activeTextField($model,'['.$i.']url', array('value'=>$model->urls[$i],'size' => 60, 'maxlength' => 255));
i also specified the following in my model rules :
public function rules()
array('url', 'required', 'on' => 'step3'),
.....
But I don’t know why the ‘required’ CSS style (small red *) appears only when a validation error occurs.
Is it a bug at Tabular input generation ?
bsander
(Sanderb)
January 27, 2010, 11:20am
2
Since url is only required in the step3 scenario, be sure to set the correct scenario even when no POST data is received. I imagine you have somehting like this:
if(isset($_POST['Model'])) {
$model = new Model;
$model->scenario = 'step3';
...
}
$this->render(...);
Where you probably want something like this for the url attribute to be required:
$model = new Model;
$model->scenario = 'step3';
if(isset($_POST['Model'])) {
...
}
$this->render(...);
saegeek
(Abdallah)
January 29, 2010, 6:06pm
3
Ok thanks, I used
$model->setScenario('step3');
and it worked fine.