65 lines
2.2 KiB
PHP
Executable File
65 lines
2.2 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Form;
|
|
|
|
use Symfony\Component\Form\AbstractType;
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
|
|
class BookmarkType extends AbstractType
|
|
{
|
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
|
{
|
|
$builder
|
|
->add('submit', SubmitType::class, [
|
|
'label' => ('delete' == $options['mode'] ? 'Confirmer la Suppression' : 'Valider'),
|
|
'attr' => ('delete' == $options['mode'] ? ['class' => 'btn btn-danger'] : ['class' => 'btn btn-success']),
|
|
])
|
|
|
|
->add('title', TextType::class, [
|
|
'label' => 'Titre',
|
|
'disabled' => ('delete' == $options['mode'] ? true : false),
|
|
])
|
|
|
|
->add('subtitle', TextareaType::class, [
|
|
'label' => 'Sous Titre',
|
|
'required' => false,
|
|
'disabled' => ('delete' == $options['mode'] ? true : false),
|
|
'attr' => ['rows' => '4'],
|
|
])
|
|
|
|
->add('color', TextType::class, [
|
|
'label' => 'Couleur',
|
|
'required' => false,
|
|
'attr' => ['class' => 'pick-a-color'],
|
|
])
|
|
|
|
->add('url')
|
|
|
|
->add('target', ChoiceType::class, [
|
|
'label' => 'Ouvrir le lien dans',
|
|
'choices' => [
|
|
'Nouvel onglet/fenêtre' => '_blank',
|
|
'iFrame' => 'frame',
|
|
'Onglet courant' => '_self',
|
|
],
|
|
])
|
|
|
|
->add('idicon', HiddenType::class, ['mapped' => false, 'data' => $options['idicon']]);
|
|
}
|
|
|
|
public function configureOptions(OptionsResolver $resolver)
|
|
{
|
|
$resolver->setDefaults([
|
|
'data_class' => 'App\Entity\Bookmark',
|
|
'mode' => 'string',
|
|
'idicon' => null,
|
|
]);
|
|
}
|
|
}
|