YiiMongoDbSuite
YiiMongoDbSuite copied to clipboard
EMongoEmbeddedDocument.php aftervalidate errors
hi, i dont know this is a bug or feature, but... i have an EMongoDocument with name attribute and it has a location embedded document the location has name attribute too like this: { name: '', location: { name: '' } }
i created a form from this if name and location.name is required too and location.name is empty but name has value in error list i see the name is empty too
i think this function adds extra error message to name attribute:
/**
* @since v1.0.8
*/
public function afterValidate()
{
if($this->hasEmbeddedDocuments())
foreach($this->_embedded as $doc)
{
if(!$doc->validate())
{
$this->addErrors($doc->getErrors());
}
}
}
sorry if it is not a real bug, im new yii/mongo user and im new on github
This must be a bug. It causes EMongoEmbeddedBehavior not to work properly. I changed to this:
/**
* @since v1.0.8
*/
public function afterValidate()
{
if($this->hasEmbeddedDocuments())
foreach($this->_embedded as $doc)
{
if(!$doc->validate())
{
$this->addErrors($doc->getErrors());
}
}
parent::afterValidate();
}