Hi All,
I am trying to write my own functions for Volt to render some form parts. I have written static method like below which is working for me alright, but I have got a few questions.
public static function form_element($form, $element, $label = true, $inline = true)
{
$di = \Phalcon\DI::getDefault();
$di->set('viewFormElement', function() {
$view = new \Phalcon\Mvc\View();
$view->setViewsDir('../app/engine/Volt/View/');
$view->registerEngines(array(
".volt" => 'voltService'
));
return $view;
});
$view = $di->get('viewFormElement');
$view->setVars(array(
'label' => true,
'form' => $form,
'element' => $element
));
$view->start();
$view->render('form', 'formElementInline');
return $view->getContent();
}
When I am trying to add $view->start() (doesn't matter if after render or after getContent()), the content is empty. If I am not adding $view->start() then it is printing the content just before generating of the main content.
Could someone please let me know why this is happening and what is the best way to do it?