deblan.tv/vendor/trinity/src/Trinity/Bundle/SlideshowBundle/Form/Type/SlideshowItemType.php
2015-03-02 21:57:49 +01:00

58 lines
1.8 KiB
PHP
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace Trinity\Bundle\SlideshowBundle\Form\Type;
use Propel\PropelBundle\Form\BaseAbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Trinity\Bundle\SlideshowBundle\Model\SlideshowItemPeer;
use Trinity\Component\Form\DataTransformer\StringToFileTransformer;
use Trinity\Component\Form\EventListener\FileDeleteFormListener;
class SlideshowItemType extends BaseAbstractType
{
protected $options = array(
'data_class' => 'Trinity\Bundle\SlideshowBundle\Model\SlideshowItem',
);
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('uid', 'hidden');
$builder->add('cmsBlockId', 'hidden');
$builder->add('rank', 'hidden', array('attr' => array('class' => 'rank')));
$builder->add('title', 'text', array('attr' => array('class' => 'title')));
$builder->add('content', 'textarea', array('required' => false));
$builder->add('link', 'text', array('required' => false,'attr' => array('class' => 'urlpicker')));
$builder->add(
$builder->create(
'picture',
'file',
array(
'data_class' => null,
'attr' => array(
'upload_dir' => SlideshowItemPeer::getUploadDir('picture')
)
)
)->addModelTransformer(new StringToFileTransformer($builder->getData(), 'picture'))
);
$builder->addEventSubscriber(
new FileDeleteFormListener(
$builder->getFormFactory(),
array(
'picture'
)
)
);
}
public function getName()
{
return 'slideshowitem';
}
}