Skip to content

Instantly share code, notes, and snippets.

@amsolucionesweb
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amsolucionesweb/1725c4959a1eb3200820 to your computer and use it in GitHub Desktop.
Save amsolucionesweb/1725c4959a1eb3200820 to your computer and use it in GitHub Desktop.
<?php
namespace AM\AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* DatosContacto
*
* @ORM\Table("avisosb_datos_contacto")
* @ORM\Entity
*/
class DatosContacto
{
.....
/**
* @var boolean
*
* @ORM\Column(name="mostrar_email", type="boolean")
*/
private $mostrarEmail;
......
/**
* Set mostrarEmail
*
* @param boolean $mostrarEmail
*
* @return \TEM\AvisosBundle\Entity\DatosContacto
*/
public function setMostrarEmail($mostrarEmail)
{
$this->mostrarEmail = $mostrarEmail;
return $this;
}
/**
* Get mostrarEmail
*
* @return boolean
*/
public function getMostrarEmail()
{
return $this->mostrarEmail;
}
....
}
<?php
namespace AM\AppBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class DatosContactoType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
...
->add('mostrarEmail', 'choice', array(
'choices' => array(
'Sí' => true,
'No' => false,
),
'choices_as_values' => true,
'required' => true,
'expanded' => true,
'placeholder' => false,
'label' => '¿Mostrar email?'
))
...
;
}
/**
* @param OptionsResolverInterface $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'TEM\AvisosBundle\Entity\DatosContacto'
));
}
/**
* @return string
*/
public function getName()
{
return 'datos_contacto';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment