2015-08-19 09:46:21 +00:00
|
|
|
<?php
|
|
|
|
|
2024-02-19 00:30:12 +00:00
|
|
|
namespace Wallabag\Form\Type;
|
2015-08-19 09:46:21 +00:00
|
|
|
|
|
|
|
use Symfony\Component\Form\AbstractType;
|
2016-11-07 08:05:04 +00:00
|
|
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
2015-12-22 09:16:34 +00:00
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
2015-08-19 09:46:21 +00:00
|
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
2024-02-19 00:30:12 +00:00
|
|
|
use Wallabag\Entity\Tag;
|
2015-08-19 09:46:21 +00:00
|
|
|
|
|
|
|
class NewTagType extends AbstractType
|
|
|
|
{
|
2023-02-07 20:18:06 +00:00
|
|
|
public const MAX_LENGTH = 40;
|
2023-06-13 09:24:27 +00:00
|
|
|
public const MAX_TAGS = 5;
|
2023-02-07 20:18:06 +00:00
|
|
|
|
2015-08-19 09:46:21 +00:00
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
|
|
|
{
|
|
|
|
$builder
|
2016-11-07 08:05:04 +00:00
|
|
|
->add('label', TextType::class, [
|
|
|
|
'required' => true,
|
|
|
|
'attr' => [
|
|
|
|
'placeholder' => 'tag.new.placeholder',
|
2023-02-07 20:18:06 +00:00
|
|
|
'max_length' => self::MAX_LENGTH,
|
2016-11-07 08:05:04 +00:00
|
|
|
],
|
|
|
|
])
|
|
|
|
->add('add', SubmitType::class, [
|
|
|
|
'label' => 'tag.new.add',
|
|
|
|
])
|
2015-08-19 09:46:21 +00:00
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function configureOptions(OptionsResolver $resolver)
|
|
|
|
{
|
2016-04-12 09:36:01 +00:00
|
|
|
$resolver->setDefaults([
|
2022-09-01 18:54:56 +00:00
|
|
|
'data_class' => Tag::class,
|
2016-04-12 09:36:01 +00:00
|
|
|
]);
|
2015-08-19 09:46:21 +00:00
|
|
|
}
|
|
|
|
|
2015-12-22 09:16:34 +00:00
|
|
|
public function getBlockPrefix()
|
2015-08-19 09:46:21 +00:00
|
|
|
{
|
|
|
|
return 'tag';
|
|
|
|
}
|
|
|
|
}
|