wallabag/src/Form/Type/NewTagType.php

45 lines
1.1 KiB
PHP
Raw Permalink Normal View History

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;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
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
{
public const MAX_LENGTH = 40;
public const MAX_TAGS = 5;
2015-08-19 09:46:21 +00:00
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('label', TextType::class, [
'required' => true,
'attr' => [
'placeholder' => 'tag.new.placeholder',
'max_length' => self::MAX_LENGTH,
],
])
->add('add', SubmitType::class, [
'label' => 'tag.new.add',
])
2015-08-19 09:46:21 +00:00
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
2022-09-01 18:54:56 +00:00
'data_class' => Tag::class,
]);
2015-08-19 09:46:21 +00:00
}
public function getBlockPrefix()
2015-08-19 09:46:21 +00:00
{
return 'tag';
}
}