<?php

namespace OfficeBrain\Bundle\OrderBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Form\FormTypeInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Validator\ExecutionContextInterface as context;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormError;
use Symfony\Component\Validator\Constraints as Assert;

class GuestInfoType extends AbstractType
{
   /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */

	/*	
	protected $coreManager;    
    public function __construct($coreManager,$addEditFlag='',$formData=array())
    {
    	$this->coreManager = $coreManager; 
    	$this->flag = $addEditFlag;
    	$this->formData = $formData;    	
    }
    */
	
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
       $builder->add('name', 'text', array(
       		'required' => false,
       		'constraints' => array(new Assert\NotBlank(array('message'=>'user.contact_book.name.not_blank'))),
       ))

       ->add('contact', 'text',array(
       		'required' => false,
       		'constraints' => array(new Assert\NotBlank(array('message'=>'user.contact_book.contact.not_blank'))),
       ))
               
       ->add('email', 'text', array(
       		'required' => false,
       		'constraints' => array(new Assert\NotBlank(array('message'=>'user.contact_book.email.not_blank')),
       							   new Assert\Regex(array('pattern' => '/^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-z]{2,4}$/','message'=>'user.contact_book.email.not_valid'))),
       ))
       
       ->add('company', 'text',array(
       			'required' => false,
       	))
       
       ->add('zipcode', 'text');      
    }
    
    /**
     * @param OptionsResolverInterface $resolver
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
         $resolver->setDefaults(array(
            'data_class' => null
        ));
    }

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