I try to make a form
In the controller I write this :
<?php
use Phalcon\Mvc\Controller;
class CrudController extends Controller
{
public function indexAction(){
$this->view->form = new CrudForm;
//print($this->view->form);
}
}
In the model I just write :
<?php
use Phalcon\Mvc\Model;
class Crud extends Model { //public $id;
public $name;
public $email;
public $city;
}
In the \forms\Crudform.php I write :
<?php
use Phalcon\Forms\Form;
use Phalcon\Forms\Element\Text;
use Phalcon\Forms\Element\Hidden;
use Phalcon\Validation\Validator\PresenceOf;
use Phalcon\Validation\Validator\Email;
class CrudForm extends Form
{
public function initialize($entity = null, $options = array())
{
if (!isset($options['edit'])) { $element = new Text("id"); $this->add($element->setLabel("Id")); } else { $this->add(new Hidden("id")); }
.......... }
.........
In the \views\crud\index.php, I try to render the form with : $form->render("name")
But, no form displayed.
Do I miss something in my codes ?