Hello Guys,
I've got a problem with phalcon in my project and I'm sure this is a issue.
I got a controller where I'm using $this->view->pick();
to pick the right view. It is rendering the right view and it's working. But on the page I got a form-element, but this form-element doesn't render.
So I debugged the code and set an exit;
on the end of the view file with the form element. In this case the form element will shown. I found out, that the problem issued when the $this->getContent();
method is finished. When I set exit;
directly after this method, the form element is deleted.
For testing I deleted all javascript includes to prevent that it will be deleted by javascript code.
Little bit code (the view):
<div class="col-md-8 no-padding no-margin">
<div class="col-md-12 big-content">
<div class="panel panel-default panel-teal">
<div class="panel-heading">
<h1 class="panel-title"><?= $lang->_('me.settings'); ?></h1>
</div>
<div class="panel-body">
<?= $this->flash->output(); ?>
<!-- Will not be shown --><?= $this->tag->form(['me/settings/store', 'method' => 'POST', 'role' => 'form', 'class' => 'form-horizontal']); ?>
<div style="display:none;">
<?= $settingsForm->render('csrf'); ?>
</div>
<div class="form-group">
<label for="settings-mail" class="col-lg-3 control-label"><?= $lang->_('me.settings.email'); ?></label>
<div class="col-lg-9">
<?= $settingsForm->render('settings-mail'); ?>
</div>
</div>
<div class="form-group">
<label for="settings-block-newfriends" class="col-lg-3 control-label"><?= $lang->_('me.settings.blocknewfriends'); ?></label>
<div class="col-lg-9">
<div class="checkbox">
<label>
<?= $settingsForm->render('settings-block-newfriends'); ?>
</label>
</div>
</div>
</div>
<!-- Will not be shown --><?= $this->tag->endForm(); ?>
</div>
</div>
</div>
</div>
<div class="col-md-4 no-padding no-margin">
<div class="col-md-12 small-content">
<?= $this->partial('shared/static-buttons'); ?>
</div>
</div>
Template View (layout folder):
<?= $this->partial('shared/navigation'); ?>
<?= $this->partial('shared/subnavigation'); ?>
<div class="container content">
<?php echo $this->getContent(); ?><!-- After this, form elements are deleted -->
</div>
Controller (will be extended in following controller):
/**
* ControllerBase
*/
class SubControllerBase extends ControllerBase
{
public function initialize()
{
parent::initialize();
}
public function beforeExecuteRoute() {
$ns = $this->dispatcher->getNamespaceName();
$c = $this->dispatcher->getControllerName();
$this->view->pick($ns . '/' . $c);
}
}
The controller:
namespace Me;
use SubControllerBase;
use SettingsForm;
/**
* SettingsController
*/
class SettingsController extends SubControllerBase
{
public function initialize()
{
parent::initialize();
$this->createSubNavigation('me', 'settings');
}
public function indexAction()
{
$this->tag->appendTitle($this->lang->_('me.settings'));
$settingsForm = new SettingsForm();
$settingsForm->setLang($this->lang);
$this->view->setVar('settingsForm', $settingsForm);
}
public function storeAction()
{
}
}
Result - you see: No form-element. Wtf?: