/**
* Index action
*
* @return array
*/
public function indexAction()
{
if ($this->getRequest()->isPost() and !$this->params('isForwarded')) {
$postData = $this->getRequest()->getPost()->toArray();
$this->form->setData($postData);
foreach ($postData as $idx => $post) {
if (is_array($post)) {
$this->form->addWidget($idx, $post);
}
}
if ($this->form->isValid()) {
$this->model->addWidgets($this->form->getData(), true);
$this->flashMessenger()->addSuccessMessage('Widgets saved');
return $this->redirect()->toRoute('module/social/addthis');
}
$this->flashMessenger()->addErrorMessage('Cannot saved widgets');
return $this->redirect()->toRoute('module/social/addthis');
}
$this->form->prepareWidgets();
if ($this->params('isForwarded') != 'config') {
$this->form->prepareConfig();
}
if ($this->params('isForwarded')) {
$this->useFlashMessenger();
}
return array('addThis' => $this->model, 'form' => $this->form);
}