Skip to content
This repository
tree: 615bcf6103
Fetching contributors…

Cannot retrieve contributors at this time

file 66 lines (59 sloc) 2.159 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
<?php

namespace Theodo\RogerCmsBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;

use Theodo\RogerCmsBundle\Entity\Page;
use Theodo\RogerCmsBundle\Repository\PageRepository;

class PageType extends AbstractType
{
    /**
* Form builder
*
* @author Vincent Guillon <vincentg@theodo.fr>
* @since 2011-06-21
*/
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        // Set inputs
        $builder->add('parent_id', 'hidden', array('required' => true));
        $builder->add('name', 'text', array('required' => true));
        $builder->add('slug', 'text', array('required' => true));
        $builder->add('breadcrumb', 'text', array('required' => false));
        $builder->add('title', 'text', array('required' => false));
        $builder->add('description', 'text', array('required' => false));
        $builder->add('keywords', 'text', array('required' => false));
        $builder->add('content', 'textarea', array('required' => false));
        $builder->add('status', 'choice', array(
            'choices' => PageRepository::getAvailableStatus(),
            'required' => true
        ));
        $builder->add('content_type', 'choice', array(
            'choices' => PageRepository::getAvailableContentTypes(),
            'required' => true
        ));
        $builder->add('cacheable', 'checkbox', array('required' => false));
        $builder->add('public', 'checkbox', array('required' => false));
        $builder->add('lifetime', 'text', array('required' => false));

        // Display published_at date only in edition
        if (null !== $options['data']->getId())
        {
            $builder->add('published_at', 'date', array('required' => false));
        }
    }

    /**
* Form default options
*
* @author Vincent Guillon <vincentg@theodo.fr>
* @since 2011-06-21
*/
    public function getDefaultOptions()
    {
        return array(
           'data_class' => 'Theodo\RogerCmsBundle\Entity\Page',
        );
    }

    public function getName()
    {
        return 'page';
    }
}
Something went wrong with that request. Please try again.