开发者

Drawbacks to Overriding the isValid() function on Zend_Form

I have overriddend the isValid() function for a form, and I was wondering if there are any drawbacks to adding logic there.

Example code:

public function isValid($data)
{
    // conditional requirement of fields

    $isValid = parent::isValid($data);

    if ($isValid) {
        // additional 开发者_运维问答validation
    }

    return $isValid;
}


No, none. But I'd put an if statement around the parent:

$parentIsValid = parent::isValid($data);
if($parentIsValid) {
    //Extra stuff, you may as well only do this if the parent valid function returns true
    //Set isValid var in here
} else $isValid = false;
return $isValid;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜