<?php

/*
 * This file is part of the FOSUserBundle package.
 *
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace AppBundle\Form;

use AppBundle\Entity\Company;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class TerritoryProfileType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $company = $options['data'];
        $company->init();
        // Common fields
        $builder
            ->add('brandName', TextType::class, array('label' => 'profile.territory.brandname'))
            ->add('description', TextareaType::class, array(
                'label' => 'profile.company.description',
                'attr' => array(
                    'class' => 'materialize-textarea'
                )
            ))
            ->add('website', UrlType::class, array(
                'label' => 'profile.company.website',
                'required' => false,
                'attr' => array(
                    'placeholder' => 'http://...'
                )));
        // Addresses fields
        $builder
            ->add('address', TextType::class, array(
                'label' => 'Adresse',
            ))
            ->add('addressComp', TextType::class, array(
                'label' => 'Complément Adresse',
                'required' => false
            ))
            ->add('zipcode', TextType::class, array(
                'label' => 'Code postal',
            ))
            ->add('city', TextType::class, array(
                'label' => 'Ville',
            ))
            ->add('country', CountryType::class, array(
                'label' => 'Pays',
            ));
        //Tags field
        $builder
            ->add('tagsComma', TextType::class, array(
                'label' => 'profile.company.tags',
                'attr' => array(
                    'data-role'=>"materialtags"
                )
            ));
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => Company::class,
            'company_addresses' => null,
        ));
    }
}
