From: Php Developer on
Hi,

I have a form where I want to force the user to fill either a text area or upload a file. I need help with that. Whey I did is not working:
$objTextArea->addRule('required', 'Please provide a text or file version')
->or_($objUpload->createRule('required', 'Please provide a text or file version'));

Thank you




From: Alexey Borzov on
Hi,

On 08.06.2010 10:51, Php Developer wrote:
> I have a form where I want to force the user to fill either a text area or upload a file. I need help with that. Whey I did is not working:
> $objTextArea->addRule('required', 'Please provide a text or file version')
> ->or_($objUpload->createRule('required', 'Please provide a text or file version'));

As there is no end-user documentation yet, consider reading at least phpdoc.
Required Rule's _or() docs:

* Disallows adding a rule to the chain with an "or" operator
*
* Required rules are different from all others because they affect the
* visual representation of an element ("* denotes required field").
* Therefore we cannot allow chaining other rules to these via or_(), since
* this will effectively mean that the field is not required anymore and the
* visual difference is bogus.

You'll need to use 'nonempty' Rule instead of 'required'.