Form integration in UDT

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Locked
chunteler
Forum Members
Forum Members
Posts: 14
Joined: Wed Oct 07, 2015 9:54 am

Form integration in UDT

Post by chunteler »

Hi,

I'm using CMSMS 1.12.
I'm busy developing a module for a customer.
I created a UDT that can be called in the content of a page to display specific info about a product.
From the UDT I call a form so that the product can be ordered. Everything has to happen within the UDT.
The form I created is not made with FormBuilder. I programmed it myself and called it action.orderform.php. It's using orderform.tpl as template.
Calling the form directly on a page works fine. It gets processed on submit.
Calling the form from the UDT and displaying it via the UDT on the page, I keep being sent back to the Home page on submit.
What did I do wrong?
I hope someone can help me.
Thanks in advance.
Attachments

[The extension txt has been deactivated and can no longer be displayed.]

[The extension txt has been deactivated and can no longer be displayed.]

[The extension txt has been deactivated and can no longer be displayed.]

calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Form integration in UDT

Post by calguy1000 »

Please read the module writing tutorial (Advanced section on the docs site).

If you have a module like this, that you are authoring then you should almost never need to use UDT's like this. You may just need to create more actions.

It may be different if you are trying to work with somebody else's module... but if it's your own module, it shouldn't be necessary.

Also, your form handling can be done in the same action/controller that outputs the form, it's cleaner and simpler this way.

Also, it is bad form to output HTML like that from within PHP code. That is what smarty templates are for. Your PHP code should just provide data to smarty, that you then format within the template.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm
Location: MI

Re: Form integration in UDT

Post by Jeff »

chunteler wrote: Calling the form from the UDT and displaying it via the UDT on the page, I keep being sent back to the Home page on submit.
When you call a module action from a page you are passing the proper variables to the action for the page. But by default those aren't passed to the UDT and then not passed when calling your action.

I agree with Calguy1000, UDT are for small pieces of code and it sounds like you have passed that point.
chunteler
Forum Members
Forum Members
Posts: 14
Joined: Wed Oct 07, 2015 9:54 am

Re: Form integration in UDT

Post by chunteler »

Thanks Jeff and Calguy1000!
I'm new to CMSMS and I thought I had to use a UDT because the customer wanted me to use a tag. Now I'm reading your reactions I realize I can do that in a much easier way with actions.
Thanks also for your feedback on Smarty.
Locked

Return to “Developers Discussion”