Skip to content

Instantly share code, notes, and snippets.

@ricardofiorani
Created October 5, 2015 20:00
Show Gist options
  • Select an option

  • Save ricardofiorani/b65fe7a5093bd12fdd00 to your computer and use it in GitHub Desktop.

Select an option

Save ricardofiorani/b65fe7a5093bd12fdd00 to your computer and use it in GitHub Desktop.
Fábio <3
<?php
/**
* Created by PhpStorm.
* User: Ricardo Fiorani
* Date: 01/10/2015
* Time: 18:23
*/
namespace Dificiometro\Application\Form;
use Zend\Form\Fieldset;
class PostFieldset extends Fieldset
{
public function init()
{
$this->add(array(
'name' => 'name',
'type' => 'Zend\Form\Element\Text',
));
$this->add(array(
'name' => 'text',
'type' => 'Zend\Form\Element\Textarea',
));
$this->add(array(
'name' => 'category',
'type' => 'DoctrineModule\Form\Element\ObjectSelect',
'options' => array(
'target_class' => 'Dificiometro\Application\Entity\Category',
'property' => 'name',
),
));
}
}
<?php
/**
* Created by PhpStorm.
* User: Ricardo Fiorani
* Date: 01/10/2015
* Time: 17:10
*/
namespace Dificiometro\Application\Form;
use Zend\Form\Form;
class PostForm extends Form
{
public function init()
{
$this->add(array(
'name' => 'post',
'type' => 'Dificiometro\Application\Form\PostFieldset',
'hydrator' => 'DoctrineModule\Stdlib\Hydrator\DoctrineObject',
'object' => 'Dificiometro\Application\Entity\Post',
));
$this->add(array(
'name' => 'submit',
'type' => 'Zend\Form\Element\Submit',
));
$this->add(array(
'name' => 'csrf',
'type' => 'Zend\Form\Element\Csrf'
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment