Skip to content

Commit

Permalink
feat: Added new DataListTextType to render HTML input with their da…
Browse files Browse the repository at this point in the history
…talist.
  • Loading branch information
roadiz-ci committed Jan 25, 2024
1 parent 35b8bc2 commit 2fe7fb9
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/Form/DataListTextType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

namespace RZ\Roadiz\CoreBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;

class DataListTextType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);

$resolver->setRequired('listName');
$resolver->setAllowedTypes('listName', 'string');
$resolver->setRequired('list');
$resolver->setAllowedTypes('list', 'array');
}

public function buildView(FormView $view, FormInterface $form, array $options): void
{
parent::buildView($view, $form, $options);

$view->vars['listName'] = $options['listName'];
$view->vars['list'] = $options['list'];
}


public function getBlockPrefix(): string
{
return 'data_list_text';
}

public function getParent(): string
{
return TextType::class;
}
}

0 comments on commit 2fe7fb9

Please sign in to comment.