Yii Framework Forum: Handling Variable Number Of Inputs - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Handling Variable Number Of Inputs

#1 User is offline   Xavier John 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 41
  • Joined: 16-August 13
  • Location:Redmond, WA

Posted 23 August 2013 - 12:42 AM

How to display the validation errors?

Right now the code just ignores models with validation errors.

foreach($_POST['Task'] as $taskData)
{
$model = new Task();
$model->setAttributes($taskData);
if($model->validate())
$models[] = $model;
}
0

#2 User is offline   CeBe 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 532
  • Joined: 16-July 10
  • Location:Berlin. Germany

Posted 23 August 2013 - 01:50 AM

Just leave out the if ():

foreach($_POST['Task'] as $taskData)
{
    $model = new Task();
    $model->setAttributes($taskData);
    $model->validate();
    $models[] = $model;
} 

0

#3 User is offline   Xavier John 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 41
  • Joined: 16-August 13
  • Location:Redmond, WA

Posted 23 August 2013 - 12:51 PM

View PostCeBe, on 23 August 2013 - 01:50 AM, said:

Just leave out the if ():
[/code]


You are right, cool. Thanks.


How do I get the error message on the screen? 'Title cannot be blank message' ?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users