About QuickForm validation

From: Date: Mon, 10 Nov 2003 16:38:34 +0000
Subject: About QuickForm validation
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-23382@lists.php.net to get a copy of this message
Hi! I have a little problem with the concept of validating elements in this class. Alexey mentioned to me: "validation in QuickForm validates not *elements* as a whole, but *values* of elements". But I think this concept could be not enough effective in some case. 1. In some situation it would be better, if an element could validate itself. Because the validation depends not only from the actual value of the element but from the actual state. For example I have an own elementtype, which need a quite huge initial data. Part of this is needed to the the validation. Now I can do something like this. $temp = &$form->addElement('type', 'name',...); $form->addRule('name',..., $temp->getValidationData(),...); But I don't like this, and is think it's not a good solution because of performance issues. The argument will passed by value. And I think this is unnecessary, bacause these data exist in the time of validation in the validated object. Or an other solution was (witch I choosed) to hack a little the QuickForm class to pass the element's object reference to the validating function if the type of the rule if 'function'. But this solution have 2 disadvantage. It's not really nice, because I shuold do something like this: function validate($submitValue, $format, &$elementObject) { return $elementObject->validate(); } Other problem is, that when a new version come out, I always have to do this hack, and for example it seems to me that it will be more difficult to achieve this behavior than in the previous version. 2. I have the same problem with the client side validation. Some time it's not enough flexible to me. This class is a very great thing, and I think it's a good idea to make the average work as simple as possible, but should give the opportunity to solve more complex situation. Felho

« previous php.pear.dev (#23382) next »