<?php

namespace OfficeBrain\Bundle\HomeSectionBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\CssSelector\XPath\Translator;
use Symfony\Component\Validator\ExecutionContextInterface;
use Symfony\Component\Form\FormTypeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;

/**
 *
 * @author OfficeBrain 4571 <info@officebrain.com>
 *
 * Decsription: HomeSection Type Form
 *
 */
class HomeSectionType extends AbstractType
{
    public function __construct()
    {
        
    }

    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        
        $builder ->add('section', 'choice', array(
                        'label' => 'Section Type',
                        'choices' => array(
                            'motivating_ideas_banner' => 'Motivating Ideas Banner',
                            'motivating_ideas_post' => 'Motivating Ideas Post',
                            'why_idme_promotions' => 'Why IDME Promotions?',
                            'we_create_fun_promos' => 'We Create Fun Promos',
                            'partners_memberships' => 'Partners & Membership',
                        ),
                        'constraints' => array(new Assert\NotBlank(array('message' => 'Home Page section is required')),
                        )
        )) ;

        $builder
            ->add('sectionHeading', 'text', array( 'label' => 'Section Heading'))
            ->add('sectionTitle', 'text', array( 'label' => 'Section Title'))
            ->add('title', 'text', array( 'label' => 'Title',
                'constraints' => array(new Assert\NotBlank(array('message' => 'Title is required'))
            )))
            ->add('description', 'textarea', array( 'label' => 'Description'))
            ->add('buttonLabel', 'text', array( 'label' => 'Button Label'))
            ->add('uploadedBanner', 'text', array( 'label' => 'Upload Image','constraints' => array(new Assert\NotBlank(array('message' => 'Image is required')),
                        )))
            ->add('link', 'text', array( 'label' => 'Url'))
             ->add('status', 'choice', array(
                  'choices'  => array('1'=>'Active', '0' =>'Inactive'),
                  'label' => 'Status'
            ))
        ;

    }

    /**
     * @param OptionsResolverInterface $resolver
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'OfficeBrain\Bundle\HomeSectionBundle\Entity\HomeSection'
        ));
    }

    /**
     * @return string
     */
    public function getName()
    {
        return 'officebrain_bundle_bannerbundle_banner';
    }
}
