Issue with custom Form submission
I defined the following form in a view php file for a plug-in I am preparing:
<form action="<?php echo Url('/profile/mems');?>" method="GET">
When the form submits, it does not gets to the method I defined as following in my code:
public function ProfileController_Mems_Create($Sender) { }
instead it goes to vanilla/index.php?memsoption=xbus1&Submit+Button=Submit
But if I type in the browser: http://mydomain/vanilla/index.php?p=/profile/mems, it goes to my method above.
Sure I am doing something wrong, but I could not find out what exactly is wrong by looking at documentation and the community.
Does anyone have any experience of defining custom forms that can submit data to a controller in code?
Appreciate if you can share your experience on this or if you have any reference to documentation/discussion related to this.
Comments
Don't bother writing out manual form markup. Use the Gdn_Form object and just open it in your view:
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
You shouldn't do it like that. Your view should use the form class of Vanilla look here for an implementation example:
https://github.com/vanilla/addons/blob/master/plugins/AuthorSelector/views/changeauthor.php
https://github.com/vanilla/addons/blob/master/plugins/AuthorSelector/class.authorselector.plugin.php#L42-82
The view only implements a submit button and the "action" is defined in the controller.
You have to create a controller for the form: