| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
how to create a form and add it to a page? | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
How to trigger doActionUpdate() in controller?
I need to add a simple form to a page that will trigger the 'update' method of the class. however, I have discovered that I can't just create a form in the template as xcart tells me the form is invalid. what do I need to do to create a simple post event? no fields, just a button that triggers the update method (doActionUpdate).
as a sidenote, does this mean that in xc5 we can't use custom forms that aren't tied to a model?? some of our clients have forms that are provided by third parties, so this might become an issue.
__________________
SEEK HAPPINESS. EVERYTHING ELSE IS DETAILS. Last edited by cvaughan02 : 05-21-2015 at 06:17 AM. Reason: more accurate title |
|||||||
#2
|
|||||||||
|
|||||||||
Re: how to create a form and add it to a page?
It is hard to answer you without seeing your code.
However, you should be able to create a controller class (a new "target"), get your custom form submitted to that target and process it there. But it is recommended to process any forms by create a form class and linking it to your controller. Check XLite/View/Form directory for examples.
__________________
Alex Solovev, Qualiteam --- User manual Video tutorials X-Cart FAQ You are welcome to press "Thanks" button if you find this post useful Click here to learn how to apply patches X-Cart Extensions |
|||||||||
#3
|
|||||||
|
|||||||
Re: how to create a form and add it to a page?
Quote:
Thanks for the reply.. yeah, I know it was a little vague. can you point me to a tutorial/doc on creating a form class? I tried searching but it just keeps bringing up stuff on how to modify the contact us form, which is not helpful. here' some clarification: I already have a page setup in the admin area. I want to add a form to it and have it submit to that same controller. my main issue is that, in the admin page I created, I couldn't figure out how to create a form that would submit to the page without giving me that error. it looks like the generated forms have an xcart-form-id which i guess is what I'm missing. btw, I did actually try just submitting my custom form to my controller. that's where I got the "this form appears to not have originated by xcart" or whatever that message says.
__________________
SEEK HAPPINESS. EVERYTHING ELSE IS DETAILS. |
|||||||
#4
|
|||||||
|
|||||||
Re: how to create a form and add it to a page?
Quote:
Please explain what name of the function that must process a form submit? Quote:
__________________
xcart5 |
|||||||
#5
|
|||||||||
|
|||||||||
Re: how to create a form and add it to a page?
Yes, you're right regarding the form id. X-Cart 5 signs most of the forms in the back-end and some of the forms in the storefront to prevent hackers from submitting malicious data in these forms.
\XLite\Controller\AController::needFormId() static method defines whether the controller class requires forms to be signed, or not. For back-end pages it always return "true", so all back-end forms are protected out of the box. There is one more method: \XLite\Controller\AController::defineFreeFormIdAct ions(). It defines a list of controller actions that should bypass the form id checking. If you want your action to skip the form id check, you should find the controller that handles the form and add the name of the action to the list generated by this method of that controller class.
__________________
Alex Solovev, Qualiteam --- User manual Video tutorials X-Cart FAQ You are welcome to press "Thanks" button if you find this post useful Click here to learn how to apply patches X-Cart Extensions |
|||||||||
|
|||
X-Cart forums © 2001-2020
|