Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

how to create a form and add it to a page?

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 05-21-2015, 05:40 AM
 
cvaughan02 cvaughan02 is offline
 

Member
  
Join Date: Mar 2014
Location: st. louis, mo
Posts: 22
 

Unhappy 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
Reply With Quote
  #2  
Old 05-21-2015, 08:40 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default 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
Reply With Quote
  #3  
Old 05-21-2015, 09:55 AM
 
cvaughan02 cvaughan02 is offline
 

Member
  
Join Date: Mar 2014
Location: st. louis, mo
Posts: 22
 

Default Re: how to create a form and add it to a page?

Quote:
Originally Posted by qualiteam
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.

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.
Reply With Quote
  #4  
Old 08-14-2015, 04:43 AM
 
Roman Prisiazniuk Roman Prisiazniuk is offline
 

Member
  
Join Date: Jun 2015
Posts: 27
 

Default Re: how to create a form and add it to a page?

Quote:
Originally Posted by qualiteam
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.

Please explain what name of the function that must process a form submit?

Quote:
Originally Posted by qualiteam
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.
How to link that form to my controller? I want to add form to my module, in what directory do I must create that form?
__________________
xcart5
Reply With Quote
  #5  
Old 08-17-2015, 12:21 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default 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
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 09:59 PM.

   

 
X-Cart forums © 2001-2020