I would love to be sure, if it is not a ugly practice to do the following.
In my controller I render a block template layout:
public function saveactionAction() {
$this->loadLayout();
$this->rendereLayout();
}
Render some simple HTML form for saving:
<form action="" method="POST">
<input name="somevar" type="text">
<input type="submit">
</form>
and in my block's template, I receive a form data, filter it and save it in the constructor:
class MyModule_MyCompany_Block_SaveAction extends Mage_Core_Block_Template {
public function __construct() {
if($params = $this->getRequest()->getParams()){
// custom filtering and saving to data database
}
parent::__constuct();
}
}
The question is: is it normal or should I do the logic inside the controller preferably?
$this->someMethod()
. So generally you would define your block and template in your layout file for the correct layout handle, then build the block and template with HTML and method calls in your template, and the methods in your block. – Jonathan Hussey Nov 30 '15 at 16:05