I have two smartforms on a single page. The forms represent info for different bank accounts and have their own submit buttons. Although the forms represent two different accounts, they are structurally the identical in that the form entities have the same variable names.
[ In fact, the forms themselves are generated using two separate instances of a custom account object. Based upon the FTL form output, I can confirm that the the account objects and the forms are actually being populated and processed correctly and distinctly. ]
Each form also has some required fields and filters. If one of the forms fails to pass the required filter, the failing form is correctly re-populated with the submitted data and the form fail messages.
But here's the sticky part: the *other* form is also populated with the posted data (though, thankfully, not the failure messages).
I assume this is something in the inVar manager. That is, when it assigns values to the various form entities, it is not distnguishing by form, but rather assigning values simply based on the entity var names, which are the same in the two the forms.
Any ideas on how to beat this?
I realize that I could manually add some prefix to the vars in each form order to distinguish them. However, I am using a form template. Separate prefixes would then require separate form templates to make the entity names in code match with the replacement names in the template which defeats some of my intention in centralizing the account processing in this external account class.
Any ideas would be greatly appreciated.
Thanks,
David
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Unfortunately I can't think of a great way around this, besides the prefix method you mention. In fact, in older versions of SiteManager we used to do autoprefixing like this, but it seemed to break more things than it fixed so we got rid of it.
The offending code here is in the loadEntity method in sfFormEntity.inc ... you'll see how it gets the data to populate the form with directly from the $_POST superglobal, and bases it on the variable name.
If you come up with something, let me know.
BTW, which version of SiteManager are you using?
Shannon
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Greetings!
I have two smartforms on a single page. The forms represent info for different bank accounts and have their own submit buttons. Although the forms represent two different accounts, they are structurally the identical in that the form entities have the same variable names.
[ In fact, the forms themselves are generated using two separate instances of a custom account object. Based upon the FTL form output, I can confirm that the the account objects and the forms are actually being populated and processed correctly and distinctly. ]
Each form also has some required fields and filters. If one of the forms fails to pass the required filter, the failing form is correctly re-populated with the submitted data and the form fail messages.
But here's the sticky part: the *other* form is also populated with the posted data (though, thankfully, not the failure messages).
I assume this is something in the inVar manager. That is, when it assigns values to the various form entities, it is not distnguishing by form, but rather assigning values simply based on the entity var names, which are the same in the two the forms.
Any ideas on how to beat this?
I realize that I could manually add some prefix to the vars in each form order to distinguish them. However, I am using a form template. Separate prefixes would then require separate form templates to make the entity names in code match with the replacement names in the template which defeats some of my intention in centralizing the account processing in this external account class.
Any ideas would be greatly appreciated.
Thanks,
David
Hi David,
Unfortunately I can't think of a great way around this, besides the prefix method you mention. In fact, in older versions of SiteManager we used to do autoprefixing like this, but it seemed to break more things than it fixed so we got rid of it.
The offending code here is in the loadEntity method in sfFormEntity.inc ... you'll see how it gets the data to populate the form with directly from the $_POST superglobal, and bases it on the variable name.
If you come up with something, let me know.
BTW, which version of SiteManager are you using?
Shannon
Hi Shannon,
Thanks for getting back to me so quickly.
Using SM 2.4.2.
In the end, I just went with prefixing and did without the form template.
Again, thanks for giving it a look. I really appreciate your advice.
Best regards,
David