<?php


namespace AutoAdmin\Bundle\Seo\Form;


use AutoAdmin\Bundle\Admin\Form\Type\AdminFormType;
use AutoAdmin\Bundle\Seo\Entity\SchemaOrgMetadata;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class SchemaOrgMetadataType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add(
            'json_ld',
            JsonTextareaType::class,
            [
                'label' => 'schema_org.form.json_ld',
                'empty_data' => '',
                'required' => false,
                'attr' => [
                    'rows' => 10,
                ],
                'help' => 'schema_org.form.json_ld.help',
                'help_html' => true,
            ]
        );

        $builder->add(
            'override',
            CheckboxType::class,
            [
                'label' => 'schema_org.form.override',
                'required' => false,
                'help' => 'schema_org.form.override.help',
            ]
        );
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        parent::configureOptions($resolver);

        $resolver->setDefault('data_class', SchemaOrgMetadata::class);
        $resolver->setDefault('label', false);
    }

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