public function createAction()
{
$translationForm = new Form\Translation();
$translationForm->prepareForm($this->getServiceLocator()->get('Config'));
$translationForm->setAttribute('action', $this->url()->fromRoute('content/translation/create'));
if ($this->getRequest()->isPost()) {
$post = $this->getRequest()->getPost();
$translationForm->setData($post->toArray());
if (!$translationForm->isValid()) {
$this->flashMessenger()->addErrorMessage('Invalid data sent !');
$this->useFlashMessenger();
} else {
$source = $post->get('source');
$data = array();
foreach ($post->get('destination') as $destinationId => $destination) {
$data[$destinationId] = array('value' => $destination);
}
foreach ($post->get('locale') as $localeId => $locale) {
if (empty($data[$localeId])) {
continue;
}
$data[$localeId]['locale'] = $locale;
}
$this->flashMessenger()->addSuccessMessage('Translation saved !');
$translator = new Translator();
$translator->setValue($source, $data);
return $this->redirect()->toRoute('content/translation/create');
}
}
return array('form' => $translationForm);
}