[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sitemanager-devel
Subject:    Re: smartForm question
From:       Shannon Weyrick <weyrick () roadsend ! com>
Date:       2002-05-14 14:32:33
[Download RAW message or body]

On Thursday 09 May 2002 11:42 am, chris hughes wrote:
> I will try more details.
>
> I am trying to keep site very modular. The smartForms get used in multiple
> places, but are not always used together. Thus, 2 forms.
>
> I am trying to avoid do my db lookup inside the forms, as my output does
> not occur inside the forms, but rather in the module that loads the forms.
>
> Here is essentially what happen:
>
> 	Module loads and adds 2 smartForms
>
> 	check inVars from smartForms
>
> 	if no input from smartForms
> 		display mesage (please input some data)
>
> 	if good input from smartForms
> 		do db lookup
>
> 	if bad input from SF
> 		display error msg (please enter good data)
> 		DONT DO LOOKUP
>
>
> I think I could solve the problem if I can figure out to reset the form
> vars AFTER verifying data. eg.
> 	if (badData == true) { badDataField = "" }
>
> How can I do this?
>
> Thanks for your help,
> c hughes
>


Hi Chris,

Are the two smartforms being loaded form XML? if so, you should be able to 
load them both into a single smartform. but, you'll have to make a bugfix to 
the library (that i've already made in the current development version)

2.2.0: smartForm.inc, line 1320
2.3.9: smSmartForm.inc, line 1414

in the loadForm() method, before the final return statement, add:
$this->xEntity = NULL;

that should allow you to load both XML forms into one smartform. you might 
also use loadForm()'s ability to return an array of which fields were added 
in that load. 

one you've got one smartform, you should be able to do a standard if block of 
dataverified() before doing the db stuff.

shannon


>
>
>
> -----Original Message-----
> From: Shannon Weyrick [mailto:weyrick@roadsend.com]
> Sent: Thursday, May 09, 2002 10:12 AM
> To: chris hughes; SiteManager mail list
> Subject: Re: smartForm question
>
> On Thursday 09 May 2002 10:52 am, chris hughes wrote:
> > Good day,
> >
> > I have a module that loads 2 smartForms, then does a db lookup based on
>
> the
>
> > content of the forms. I haven't been able to figure out how to stop the
> > db lookup if the form fields are not verified inthe smartForm(eg.
> > improper characters, etc.) Any ideas? I am using SM 2.2.0. Many thanks.
> >
> > c hughes
>
> Well, it depends on exactly how you've laid out the module..
>
> If you have two smartforms in one module, you could potentially have two
> dataVerified()'s. Do the smartforms always both load, or does one load only
> if the other was verified? otherwise, why would they be seperate forms?
>
> In any case, why can't the database code go inside dataVerified() as per
> normal, after you attach the correct filters to the form entities.. that
> way the code in dataVerified shouldn't run until the filters pass their
> checks.
>
> I'm sure there's more to it than that, but you'd have to explain more.
>
> Shannon

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic