86 lines
3.3 KiB
PHP
86 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace Cadoles\PortalBundle\Form;
|
|
|
|
use Symfony\Component\Form\AbstractType;
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
|
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
|
use Symfony\Component\Form\CallbackTransformer;
|
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|
use Ivory\CKEditorBundle\Form\Type\CKEditorType;
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
|
use Tetranz\Select2EntityBundle\Form\Type\Select2EntityType;
|
|
|
|
class FluxType extends AbstractType
|
|
{
|
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
|
{
|
|
$builder
|
|
->add("submit", SubmitType::class, [
|
|
"label" => ($options["mode"]=="delete"?"Confirmer la Suppression":"Valider"),
|
|
"attr" => ($options["mode"]=="delete"?array("class" => "btn btn-danger"):array("class" => "btn btn-success"))
|
|
])
|
|
|
|
->add('title', TextType::class, [
|
|
'label' => 'Titre'
|
|
])
|
|
|
|
->add('url', TextType::class, [
|
|
'label' => 'URL'
|
|
])
|
|
|
|
->add('maxread', IntegerType::class, [
|
|
'label' => "Nombre d'Articles affiché"
|
|
])
|
|
|
|
->add('color', TextType::class, [
|
|
'required' => false,
|
|
'attr' => array("class" => "pick-a-color")
|
|
])
|
|
|
|
->add('roles', ChoiceType::class, [
|
|
"label" => 'Visible pour les Rôles',
|
|
"choices" => [
|
|
"Visiteur" => 'ROLE_ANONYME',
|
|
"Utilisateur" => 'ROLE_USER',
|
|
"Modérateur" => 'ROLE_MODO',
|
|
"Administateur" => 'ROLE_ADMIN',
|
|
],
|
|
"multiple" => true,
|
|
"expanded" => true,
|
|
"disabled" => ($options["mode"]=="delete"?true:false),
|
|
])
|
|
|
|
->add('groups', Select2EntityType::class, [
|
|
'label' => 'Visible pour les Groupes',
|
|
'class' => 'CadolesCoreBundle:Group',
|
|
'text_property' => 'label',
|
|
'multiple' => true,
|
|
'remote_route' => 'cadoles_core_ajax_group_list',
|
|
'primary_key' => 'id',
|
|
'text_property' => 'label',
|
|
'minimum_input_length' => 0,
|
|
'page_limit' => 100,
|
|
'allow_clear' => true,
|
|
'delay' => 250,
|
|
'cache' => false,
|
|
'cache_timeout' => 60000,
|
|
'language' => 'fr',
|
|
'placeholder' => 'Selectionner un groupe',
|
|
]);
|
|
|
|
}
|
|
|
|
public function configureOptions(OptionsResolver $resolver)
|
|
{
|
|
$resolver->setDefaults([
|
|
'data_class' => 'Cadoles\PortalBundle\Entity\Flux',
|
|
'mode' => "string",
|
|
]);
|
|
}
|
|
}
|