Hi Blake,

 

You can’t have bindings in Validators, so the compiler is parsing required="{usePurchaseOrder.selected}" to either true or false – and it looks like true from what you’re saying. It’d be good if the compiler helper a bit more here, but it doesn’t.

 

We don’t think Cairngorm store has any bindings on validators – please let us know if it does.

 

For what you’re wanting to do, you’re best bet will be to drop into ActionScript and change your validators at runtime.

 

Cheers,

 

Ali

 

--

Alistair McLeod

Development Director

iteration::two

 

[EMAIL PROTECTED]

Office: +44 (0)131 338 6108

 

This e-mail and any associated attachments transmitted with it may contain confidential information and must not be copied, or disclosed, or used by anyone other than the intended recipient(s). If you are not the intended recipient(s) please destroy this e-mail, and any copies of it, immediately.

 

Please also note that while software systems have been used to try to ensure that this e-mail has been swept for viruses, iteration::two do not accept responsibility for any damage or loss caused in respect of any viruses transmitted by the e-mail. Please ensure your own checks are carried out before any attachments are opened.

 


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Blake Kadatz
Sent: 09 August 2005 22:26
To: flexcoders@yahoogroups.com
Subject: [flexcoders] StringValidator and required fields

 

I've been playing around with validators and seem to have encountered a behavior which is unexpected.  Here's a sample of what I'm doing:

 

-------------------

[snip...]

 

<mx:Model id="paymentInformationModel">
    <usepurchaseorder>{ usePurchaseOrder.selected }</usepurchaseorder>
    <purchaseordernumber>{ purchaseOrderNumber.text }</purchaseordernumber>
</mx:Model>

 

<mx:StringValidator field="paymentInformationModel.purchaseordernumber" required="{usePurchaseOrder.selected}" />

<mx:Form width="100%">
    <mx:FormHeading label="Purchase Order" />

 

    <mx:FormItem label="Pay using purchase order" required="false">
        <mx:CheckBox id="usePurchaseOrder" label=""/>
    </mx:FormItem>
  
    <mx:FormItem label="Purchase Order Number" required="{usePurchaseOrder.selected}"

            enabled="{usePurchaseOrder.selected}">
        <mx:TextInput id="purchaseOrderNumber" width="100" maxChars="50" />
    </mx:FormItem>
</mx:Form>

 

[...snip]

----------------------

 

(This is modified from the Cairngorm store and uses the Validator.isStructureValid call in the same way.)

 

This displays correctly -- the user clicks the checkbox to use a purchase order and the field becomes enabled and displays an asterisk beside it.  But if the user leaves it unchecked, then upon submitting the form it still thinks the field is required.  The telling part is that if I change the StringValidator to have required="false" instead of required="{usePurchaseOrder.selected}" then it correctly sees it as not required.

 

What am I missing here?

 

Thanks,

 

Blake




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Computer software testing Macromedia flex Development
Software developer


YAHOO! GROUPS LINKS




Reply via email to