<?php
namespace App\Form;
use App\Entity\Company;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
//use Symfony\Component\Form\Extension\Core\Type\ChoiceList;
class CompanyType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('business_name',null,[
'label'=>'Denomination entreprise'])
->add('street_address',null,[
'label'=>'Adresse'])
->add('state',null,[
'label'=>'Ville'])
->add('fixe_phone',null,[
'label'=>'Tel Fixe',
'required' => false,
])
->add('fax_number',null,[
'label'=>'Fax',
'required' => false,])
->add('mobile')
->add('email')
->add('website',null,[
'label'=>'Site web',
'required' => false,])
->add('categories',ChoiceType::class,[
'choices'=>$this->getChoices()
]
)
->add('city',null,[
'label'=>'Commune'])
->add('description')
->add('contact_name')
->add('key_words',null,[
'label'=>'Mots cles'])
->add('company_presentation')
->add('year_established',null,[
'label'=>'Date de creation'])
->add('facebook', null, [
'label'=>'Facebook',
'required' => false,
])
->add('visite',null,[
'label'=>'Souhaitez-vous recevoir notre commercial '])
->add('annonce',null,[
'label'=>'Souhaitez-vouz avoir une annonce sur les annaires'])
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Company::class,
]);
}
private function getChoices()
{
$choices=Company::CATEGORY;
$output=[];
foreach ($choices as $key => $value) {
$output[$value]=$key;
}
return $output;
}
}