Support visibility for tags (#4086)
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Tag;
|
||||
use App\Form\Type\YesNoType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@@ -32,6 +33,10 @@ class TagEditForm extends AbstractType
|
||||
'description' => 'The tag name (forbidden character: comma)',
|
||||
],
|
||||
])
|
||||
->add('visible', YesNoType::class, [
|
||||
'label' => 'visible',
|
||||
'help' => 'help.visible',
|
||||
])
|
||||
;
|
||||
$this->addColor($builder);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ final class TagToolbarForm extends AbstractType
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$this->addVisibilityChoice($builder);
|
||||
$this->addSearchTermInputField($builder);
|
||||
$this->addPageSizeChoice($builder);
|
||||
$this->addHiddenPagination($builder);
|
||||
|
||||
@@ -59,6 +59,7 @@ final class TagsSelectType extends AbstractType
|
||||
}
|
||||
|
||||
$newData = [];
|
||||
/** @var array<string> $newNames */
|
||||
$newNames = [];
|
||||
foreach ($tagIds as $tag) {
|
||||
if (!\in_array($tag, $foundIds, true)) {
|
||||
@@ -68,8 +69,10 @@ final class TagsSelectType extends AbstractType
|
||||
}
|
||||
}
|
||||
|
||||
// in case someone is using tags like "1234" this can interfere with the ID
|
||||
$tags = $this->tagRepository->findTagsByName($newNames);
|
||||
// 1. in case someone is using tags like "1234" this can interfere with the ID
|
||||
// 2. if we would load only visible tags, we would try to create new ones below
|
||||
// and that would trigger the unique constraint
|
||||
$tags = $this->tagRepository->findTagsByName($newNames, null);
|
||||
$foundTagNames = [];
|
||||
foreach ($tags as $tag) {
|
||||
$newData[] = (string) $tag->getId();
|
||||
|
||||
Reference in New Issue
Block a user