Hi Expert, having problems about Phalcon\Forms\form after submitting data to form got error
(the form) bizRegisterForm.php
<?php
use Phalcon\Forms\Form;
use Phalcon\Forms\Element\Text;
use Phalcon\Forms\Element\Select;
use Phalcon\Validation\Validator\PresenceOf;
use Phalcon\Validation\Validator\Email;
class bizRegisterForm extends Form
{
public function initialize($entity = null, $options = null)
{
$businessname = new Text('businessname', [
'placeholder' => 'Use Your Business Trading name'
]);
$businessname->setFilters(['string']);
$businessname->addValidators([
new PresenceOf([
'message' => 'The Business Name is required'
])
]);
$this->add($businessname);
$businessemail = new Text('businessemail', [
'placeholder' => 'e.g. [email protected]'
]);
$businessemail->setFilters(['email']);
$businessemail->addValidators([
new PresenceOf([
'message' => 'The business e-mail is required'
]),
new Email([
'message' => 'The business e-mail is not valid'
]),
]);
$this->add($businessemail);
}
}
The Controller
<?php
class BusinessController extends ControllerBase
{
public function indexAction()
{
$form = new registerForm();
// other code ../
$this->view->form = $form
}
public function registerAction()
{
$registerform = new bizRegisterForm;
if($this->request->isPost())
{
$bussiness->business_name = $this->request->getPost('businessname');
$bussiness->phone = $this->request->getPost('businessphone');
// other code ...
if($bussiness->save())
{
$this->flash->success('fyes please');
}
$this->flash->error($bussiness->getMessages());
}
$this->view->form = $registerform;
}
}
register.volt
{{form('id':'register-form', 'class':'form')}}
<div class="form-group">
{{form.render("businessname")}}
</div>
<div class="form-group">
{{form.render('businessphone')}}
</div>
// the rest of the code
<div class="form-group">
<button autocomplete="off" class="button button-full button-primary" type="submit">
<span class="button-text">Next</span>
</button>
</div
{{end_form()}}
Submited form got this error Notice: Undefined variable: form in blabla balb Fatal error: Call to a member function render() on a non-object in same line any advice from the expert very appreciated