121 lines
3.3 KiB
PHP
121 lines
3.3 KiB
PHP
<?php
|
||
|
||
namespace Deblan\Bundle\BlogBundle\Form\Type;
|
||
|
||
use Propel\PropelBundle\Form\BaseAbstractType;
|
||
use Symfony\Component\Form\FormBuilderInterface;
|
||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||
use Symfony\Component\Validator\Constraints\Email;
|
||
use Symfony\Component\Validator\Constraints\Url;
|
||
|
||
class CommentType extends BaseAbstractType
|
||
{
|
||
protected $options = array(
|
||
'data_class' => 'Deblan\Bundle\BlogBundle\Model\Comment',
|
||
'name' => 'comment',
|
||
);
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||
{
|
||
$builder->add(
|
||
'Post',
|
||
'model',
|
||
array(
|
||
'label' => 'Article',
|
||
'class' => 'Deblan\Bundle\BlogBundle\Model\Post',
|
||
'query' => \Deblan\Bundle\BlogBundle\Model\PostQuery::create()->orderByTitle(),
|
||
'multiple' => false,
|
||
'expanded' => false,
|
||
'constraints' => array(
|
||
new NotBlank(),
|
||
)
|
||
)
|
||
);
|
||
|
||
$builder->add(
|
||
'ParentComment',
|
||
'model',
|
||
array(
|
||
'label' => 'Réponse à',
|
||
'class' => 'Deblan\Bundle\BlogBundle\Model\Comment',
|
||
'query' => \Deblan\Bundle\BlogBundle\Model\CommentQuery::create()
|
||
->orderByCreatedAt()
|
||
->filterByPost($builder->getData()->getPost())
|
||
->filterById($builder->getData()->getId(), \Criteria::NOT_EQUAL)
|
||
->filterByActive(true),
|
||
'multiple' => false,
|
||
'expanded' => false,
|
||
'required' => false,
|
||
'constraints' => array(
|
||
)
|
||
)
|
||
);
|
||
|
||
$builder->add(
|
||
'Author',
|
||
'text',
|
||
array(
|
||
'label' => 'Auteur',
|
||
'attr' => array('class' => 'form-control'),
|
||
'required' => true,
|
||
'constraints' => array(
|
||
new NotBlank(),
|
||
)
|
||
)
|
||
);
|
||
|
||
$builder->add(
|
||
'Website',
|
||
'url',
|
||
array(
|
||
'label' => 'Site web',
|
||
'attr' => array('class' => 'form-control'),
|
||
'required' => false,
|
||
'constraints' => array(
|
||
new Url(),
|
||
)
|
||
)
|
||
);
|
||
|
||
$builder->add(
|
||
'Email',
|
||
'email',
|
||
array(
|
||
'label' => 'Email',
|
||
'attr' => array('class' => 'form-control'),
|
||
'required' => false,
|
||
'constraints' => array(
|
||
new Email(),
|
||
)
|
||
)
|
||
);
|
||
|
||
$builder->add(
|
||
'Content',
|
||
'textarea',
|
||
array(
|
||
'attr' => array(
|
||
'class' => 'form-control',
|
||
'rows' => 3,
|
||
),
|
||
'label' => 'Contenu',
|
||
'required' => true,
|
||
'constraints' => array(
|
||
new NotBlank(),
|
||
)
|
||
)
|
||
);
|
||
|
||
$builder->add(
|
||
'Active',
|
||
'checkbox',
|
||
array(
|
||
'label' => 'En ligne',
|
||
)
|
||
);
|
||
}
|
||
}
|