I am building a custom form input type and i'm a little confused about how to implement it's validation in the official documentation : https://symfony.com/doc/current/form/create_custom_field_type.html
My field type basically allows the user to insert as many values as he want's. It is handled by JavaScript and is rendered as a hidden input that holds the values as a JSON array.
The script works well, now all i need to do is make sure that the input value contains a valid single-dimension JSON array in case the user messes with it using his browser's dev tools and i'd like this to be handle by the input class to maximize the field re-usability.
How can i achieve that ?
Here's my input class, but it's pretty much empty :
<?php
namespace App\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
class ListType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([]);
}
public function getParent()
{
return HiddenType::class;
}
}
Thanks