135 lines
3.1 KiB
PHP
135 lines
3.1 KiB
PHP
<?php
|
|
|
|
|
|
class stModalFrontendActions extends stActions
|
|
{
|
|
|
|
const TextTPL = [
|
|
'example' => 'modal_text_example.html',
|
|
'mymodal' => 'modal_text_mymodal.html',
|
|
];
|
|
|
|
|
|
public function executeRenderModalText()
|
|
{
|
|
$modal = $this->getRequestParameter('modal');
|
|
|
|
return $this->renderTextTpl($modal);
|
|
|
|
}
|
|
|
|
|
|
public function renderTextTpl($modal)
|
|
{
|
|
$smarty = new stSmarty($this->getModuleName());
|
|
return $this->renderText($smarty->fetch(self::TextTPL[$modal]));
|
|
}
|
|
|
|
|
|
// Modal example form
|
|
|
|
public function executeModalFormExample()
|
|
{
|
|
$this->smarty = new stSmarty($this->getModuleName());
|
|
|
|
$this->modal = $this->getRequestParameter('modal');
|
|
|
|
$this->my_form_data = "";
|
|
|
|
if ($this->getRequest()->getMethod() == sfRequest::POST)
|
|
{
|
|
$my_form_data = $this->getRequestParameter('my_form');
|
|
|
|
$this->my_form_data = $my_form_data;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public function validateModalFormExample()
|
|
{
|
|
$i18n = $this->getContext()->getI18n();
|
|
|
|
$error_exists = false;
|
|
|
|
if ($this->getRequest()->getMethod() == sfRequest::POST){
|
|
|
|
$my_form = $this->getRequestParameter('my_form');
|
|
|
|
if (!$my_form['field_1']){
|
|
|
|
$this->getRequest()->setError('my_form{field_1}', $i18n->__('Proszę uzupełnić pole'));
|
|
|
|
$error_exists = true;
|
|
}
|
|
|
|
}
|
|
|
|
return !$error_exists;
|
|
|
|
}
|
|
|
|
public function handleErrorModalFormExample()
|
|
{
|
|
$this->smarty = new stSmarty($this->getModuleName());
|
|
|
|
$this->my_form_data = "";
|
|
$this->modal = $this->getRequestParameter('modal');
|
|
|
|
return sfView::SUCCESS;
|
|
}
|
|
|
|
|
|
// Modal mymodal form
|
|
|
|
public function executeModalFormMymodal()
|
|
{
|
|
$this->smarty = new stSmarty($this->getModuleName());
|
|
|
|
$this->modal = $this->getRequestParameter('modal');
|
|
|
|
$this->my_form_data = "";
|
|
|
|
if ($this->getRequest()->getMethod() == sfRequest::POST)
|
|
{
|
|
$my_form_data = $this->getRequestParameter('my_form');
|
|
|
|
$this->my_form_data = $my_form_data;
|
|
}
|
|
}
|
|
|
|
|
|
public function validateModalFormMymodal()
|
|
{
|
|
$i18n = $this->getContext()->getI18n();
|
|
|
|
$error_exists = false;
|
|
|
|
if ($this->getRequest()->getMethod() == sfRequest::POST){
|
|
|
|
$my_form = $this->getRequestParameter('my_form');
|
|
|
|
if (!$my_form['field_1']){
|
|
|
|
$this->getRequest()->setError('my_form{field_1}', $i18n->__('Proszę uzupełnić pole'));
|
|
|
|
$error_exists = true;
|
|
}
|
|
|
|
}
|
|
|
|
return !$error_exists;
|
|
}
|
|
|
|
public function handleErrorModalFormMymodal()
|
|
{
|
|
$this->smarty = new stSmarty($this->getModuleName());
|
|
|
|
$this->my_form_data = "";
|
|
$this->modal = $this->getRequestParameter('modal');
|
|
|
|
return sfView::SUCCESS;
|
|
}
|
|
}
|
|
|