mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-14 20:35:08 +02:00
Added a simple autocomplete mechanism for the footprint URL.
This commit is contained in:
parent
4675793c24
commit
3277d98ee2
10 changed files with 180 additions and 6 deletions
|
@ -45,6 +45,8 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
|
|||
use Symfony\Component\Form\Extension\Core\Type\UrlType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Routing\RouterInterface;
|
||||
use Symfony\Component\Validator\Constraints\File;
|
||||
use Symfony\Component\Validator\Constraints\Url;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
@ -53,11 +55,13 @@ class AttachmentFormType extends AbstractType
|
|||
{
|
||||
protected $attachment_helper;
|
||||
protected $trans;
|
||||
protected $urlGenerator;
|
||||
|
||||
public function __construct(AttachmentHelper $attachmentHelper, TranslatorInterface $trans)
|
||||
public function __construct(AttachmentHelper $attachmentHelper, TranslatorInterface $trans, UrlGeneratorInterface $urlGenerator)
|
||||
{
|
||||
$this->attachment_helper = $attachmentHelper;
|
||||
$this->trans = $trans;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
|
@ -79,6 +83,8 @@ class AttachmentFormType extends AbstractType
|
|||
$builder->add('url', TextType::class, [
|
||||
'label' => $this->trans->trans('attachment.edit.url'),
|
||||
'required' => false,
|
||||
'attr' => ['data-autocomplete' => $this->urlGenerator->generate('typeahead_builtInRessources', ['query' => 'QUERY'])
|
||||
],
|
||||
'constraints' => [
|
||||
$options['allow_builtins'] ? new UrlOrBuiltin() : new Url()
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue