Determining the form action

Permalink
Hello,

I am very new to Concrete5 and have created a package with a block within it. From within my block's view.php, I can direct a form's action to my blocks' controller.php "action_something" function by calling $this->action('something'). However, this renders a not so user friendly address and presents the users with something like "index.php?cID=1&bID=12&arHandle=Main.........". Basically a very, very long address. Is there any way to avoid this? Isn't there a pretty URL which I can just write in my form's action to make my "action_something" function execute? Perhaps I have to redirect the user after doing whatever I have to do within that function?

Also, I am wondering what I would generally use my package's controller for except installing/uninstalling. Like what I would put in the block's controller and what belongs to the package's controller. Say, for instance, that I want to make a post request to a function in my package's controller; which URL would I use? Can I render a view from my package controller? I come from a more strict MVC background, so I find the concept of so many different controllers rather confusing.

I apologize for the amount of questions, but some things are slightly difficult to grasp at first, and the documentation is not always very helpful.

Thanks in advance!

 
Sadu replied on at Permalink Reply
Sadu
Personally I'm ok with using ugly URLs in POST requests as the user will never see them. It's best practice to redirect afterwards anyway to avoid the user doing a refresh and double-posting so I'd suggest just doing that.

Another approach is to submit your form via AJAX so the user doesn't have to leave the page.

Or you could create a single page with pretty URLs to handle the form submissions - probably more work than the redirect option though.
JohntheFish replied on at Permalink Reply
JohntheFish
The main use for a package controller after a package has been installed is for events. To set up event handlers and (unless they are trivial), direct them to a tool or method in a library.

If you want to target a post request at something other than the block controller or a block tool, it will usually be to a package tool or single page controller within the package.
andy17 replied on at Permalink Reply
Thanks for the replies.

I ended up using <?php echo View::url($c->getCollectionPath()); ?>. :-)