Dynamically add field if input item is selected?
Posted: 19 December 2010 06:15 AM   [ Ignore ]
Has a Great Personality
Rank
Total Posts:  49
Joined  2010-12-07

I’m trying to dynamically add a field to a form if a radio button value is selected, but am having trouble getting it to work.  I’ve tried doing this using EE {if} statements, but I don’t think it’s evaluating the {if} when the Submit button is clicked, only when the template is rendered.

I’ve also tried doing this in Javascript on a form, but the POST contains a hash that a 3rd-party shopping cart service needs to receive and dynamically adding the field via JS causes that hash check to fail once redirected.

Is there a way to run POST/output validation without putting straight PHP in the template?  All the validation entries in the Usage guide seem to be explicitly geared towards errors.

I’m still in my noob phase with EE, so any assistance would be greatly appreciated.

Profile
 
 
Posted: 20 December 2010 09:16 PM   [ Ignore ]   [ # 1 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29
Samuel Allen | No1 - 19 December 2010 06:15 AM

I’m trying to dynamically add a field to a form if a radio button value is selected, but am having trouble getting it to work.

So you’re saying you have a radio button on the entry form page, and if the user selects it, a new field appears? If I’m understanding this correctly, you’d HAVE to do this with JS.

I’ve tried doing this using EE {if} statements, but I don’t think it’s evaluating the {if} when the Submit button is clicked, only when the template is rendered.

That’s exactly right, those EE {if} statements and processed once, when the page is rendered.

I’ve also tried doing this in Javascript on a form, but the POST contains a hash that a 3rd-party shopping cart service needs to receive and dynamically adding the field via JS causes that hash check to fail once redirected.

Maybe a bit more detail on the service your using, or more specifically, how it works?

Is there a way to run POST/output validation without putting straight PHP in the template?  All the validation entries in the Usage guide seem to be explicitly geared towards errors.

What kind of validation are you trying to do?

Profile
 
 
Posted: 20 December 2010 09:36 PM   [ Ignore ]   [ # 2 ]
Has a Great Personality
Rank
Total Posts:  49
Joined  2010-12-07

The service is Integrity Payment Systems and we’re using their QuickClick package.  By validation, I meant using the validation stage to do an if->then check to insert the field.  Forgive my ignorance, but if ExpressionEngine can’t process tags except on rendering, then what does the Allow PHP on Output functionality do?  I’m presuming that these tags are all shorthand for PHP anyway, no?

Profile
 
 
Posted: 20 December 2010 09:37 PM   [ Ignore ]   [ # 3 ]
Has a Great Personality
Rank
Total Posts:  49
Joined  2010-12-07

Sorry, I hit submit before thanking you for your quick reply.  Cheers!

Profile
 
 
Posted: 20 December 2010 09:47 PM   [ Ignore ]   [ # 4 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29
Samuel Allen | No1 - 20 December 2010 09:36 PM

The service is Integrity Payment Systems and we’re using their QuickClick package.  By validation, I meant using the validation stage to do an if->then check to insert the field.  Forgive my ignorance, but if ExpressionEngine can’t process tags except on rendering, then what does the Allow PHP on Output functionality do?  I’m presuming that these tags are all shorthand for PHP anyway, no?

PHP on output means it will process your template’s php AFTER it processes your template tags. On input means it will process your php BEFORE processing your template tags. But whether it’s PHP or template tags, it’s executed at the time of rendering.

Profile
 
 
Posted: 20 December 2010 10:57 PM   [ Ignore ]   [ # 5 ]
Has a Great Personality
Rank
Total Posts:  49
Joined  2010-12-07

Thanks for the clarification!

Profile