Sorry I was not precise enough.
My question is: What is the method setAction() good for, if it is not used when the form is rendered?
I expected that when I call in my controller (see below): $form->setAction('controller1/action1'); that phalcon renders the form in the view with that action.
In my controller I do this:
$form = new SettingsTypeForm();
if ($this->request->isPost()) {
$form->initialize($this->request->getPost());
}
$this->view->form = $form;
I build my forms in extra classes, e.g. SettingsTypeForm.php - FormBase extends Phalcon's Form-Class.
<?php
namespace SlipBOX\Forms;
use Phalcon\Forms\Form,
Phalcon\Forms\Element\Text,
Phalcon\Validation\Validator\PresenceOf;
use SlipBOX\Forms\FormBase;
class SettingsTypeForm extends FormBase
{
public function initialize ($type = null, $options = null)
{
$this->add($this->_elementTitle());
$this->add($this->_elementFields());
parent::initialize($type, $options);
}
private function _elementTitle ()
{
$text = new Text('title', array(
'id' => 'title',
'required' => 'required',
'class' => 'form-control',
'placeholder' => 'PLACEHOLDER_ENTITIESTYPES_TITLE'
));
$text->setLabel("LABEL_ENTITIESTYPES_TITLE");
$text->addValidators(array(
new PresenceOf(array(
'message' => $this->_getTranslation('errors')->_('VALIDATION_FIELD_PRESENCEOF', array('field'=>'title'))
))
));
return $text;
}
private function _elementFields ()
{
$element = new Text('fields', array(
'id' => 'fields',
'required' => 'required',
'class' => 'form-control',
'placeholder' => 'PLACEHOLDER_ENTITIESTYPES_FIELDS'
));
$element->setLabel("LABEL_ENTITIESTYPES_FIELDS");
return $element;
}
}