Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

form render problem

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 ?



38.6k
Accepted
answer

Might be only a typo, but the extension of view files should be phtml instead of php



1.5k

thank you Lajos Bencz