MonOve
MonOve

Reputation: 1101

Validate using model rules before saving in Yii

I am building a CSV import, and am looking to run through the CSV and display any potential errors to the user before actually doing the import.

$model->getErrors() only works after an attempted $model->save(), I am looking to get those potential errors before the save so the importer can then adjust his CSV file and make the necessary changes to have a flawless import.

Any ideas?

Upvotes: 0

Views: 966

Answers (2)

christian
christian

Reputation: 558

at first place, why dont you try this tool wrote by me: http://www.yiiframework.com/wiki/401/simple-csv-export/

Upvotes: 0

MonOve
MonOve

Reputation: 1101

$model->validate(); $model->getErrors();

Upvotes: 3

Related Questions