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

I've been working on this trying to figure out the best way to handle
it.  The compiler nicely informs me that id tags aren't supported on
validators, so it appears setting the required property on a validator
isn't directly possible.

The only way I can determine is that I should be calling the validator's
disable method, eg:

http://livedocs.macromedia.com/flex/15/asdocs_en/mx/validators/Validator
.html#disable

So I modified the PaymentInformation.mxml to have:

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

  <mx:StringValidator
field="paymentInformationModel.purchaseordernumber"
      requiredFieldError="Please enter your purchase order number." />

Then, in CheckoutViewHelper.as, I modified it to have:

  public function validateCheckOutForm() : Boolean
  {
    var validStructures : Number = 0;
    var structuresToBeValidated : Number = 2;

    // manually set required for non-binding validators
    if (view.paymentInformationComp.usePurchaseOrder.selected)
    {
      mx.validators.Validator.enable(view,
         "paymentInformationModel.purchaseordernumber");
    }
    else
    {
      mx.validators.Validator.disable(view,
         "paymentInformationModel.purchaseordernumber");
    }

    ... etc ...
  }

However, this doesn't seem to work.  I've tried passing in
"purchaseOrderNumber" and other variations to the disable and enable
methods, but it still shows up as being a required field.

I hope I'm missing something obvious -- my next step would be to use a
generic Validator with a custom validate() function, which all seems
rather messy.

Thanks,

Blake


------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12h65lnr9/M=362131.6882499.7825260.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1123702726/A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org
">Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life 
- brought to you by One Economy</a>.</font>
--------------------------------------------------------------------~-> 

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

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to