Bonjour,
je cherche a faire un formulaire pour un slider qui aurait une image et un titre en francais et ou en anglais.
je cherche a mettre dans le form un tab pill boostrap mais je vous pas comment.
ou un bouton qui switch un input de fr a en.
voici les entity
<?php
namespace Cz\AdminBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Carrousel
*
* @ORM\Table(name="cz_adminbundle_carrousel")
* @ORM\Entity(repositoryClass="Cz\AdminBundle\Repository\CarrouselRepository")
*/
class Carrousel extends \Kunstmaan\AdminBundle\Entity\AbstractEntity
{
/**
* @var string
*
* @ORM\Column(name="format", type="boolean")
*/
private $format;
/**
* @ORM\OneToOne(targetEntity="Cz\AdminBundle\Entity\MediaAdmin", cascade={"persist","remove"})
* @ORM\JoinColumn(nullable=false)
*/
private $image;
/**
* @ORM\OneToOne(targetEntity="Cz\AdminBundle\Entity\CarrouselName", cascade={"persist","remove"})
* @ORM\JoinColumn(nullable=false)
*/
private $locale;
/**
* @var boolean
*
* @ORM\Column(name="fleche", type="boolean")
*/
private $fleche;
/**
* Set format
*
* @param string $format
*
* @return Carrousel
*/
public function setFormat($format)
{
$this->format = $format;
return $this;
}
/**
* Get format
*
* @return string
*/
public function getFormat()
{
return $this->format;
}
/**
* Set image
*
* @param \Cz\AdminBundle\Entity\MediaAdmin $image
* @return Produits
*/
public function setImage(\Cz\AdminBundle\Entity\MediaAdmin $image)
{
$this->image = $image;
return $this;
}
/**
* Get image
*
* @return \Cz\AdminBundle\Entity\MediaAdmin
*/
public function getImage()
{
return $this->image;
}
/**
* Set fleche
*
* @param boolean $fleche
*
* @return Carrousel
*/
public function setFleche($fleche)
{
$this->fleche = $fleche;
return $this;
}
/**
* Get fleche
*
* @return boolean
*/
public function getFleche()
{
return $this->fleche;
}
/**
* Set locale
*
* @param \Cz\AdminBundle\Entity\CarrouselName $locale
*
* @return Carrousel
*/
public function setLocale(\Cz\AdminBundle\Entity\CarrouselName $locale)
{
$this->locale = $locale;
return $this;
}
/**
* Get locale
*
* @return \Cz\AdminBundle\Entity\CarrouselName
*/
public function getLocale()
{
return $this->locale;
}
}
<?php
namespace Cz\AdminBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Carrousel
*
* @ORM\Table(name="cz_adminbundle_carrousel_name")
* @ORM\Entity(repositoryClass="Cz\AdminBundle\Repository\CarrouselRepository")
*/
class CarrouselName extends \Kunstmaan\AdminBundle\Entity\AbstractEntity
{
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=255)
*/
private $title;
/**
* @var string
*
* @ORM\Column(name="locale", type="string", length=255)
*/
private $locale;
/**
* Set title
*
* @param string $title
*
* @return CarrouselName
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set locale
*
* @param string $locale
*
* @return CarrouselName
*/
public function setLocale($locale)
{
$this->locale = $locale;
return $this;
}
/**
* Get locale
*
* @return string
*/
public function getLocale()
{
return $this->locale;
}
}
les formulaire imbriquer:
<?php
namespace Cz\AdminBundle\Form;
use Cz\AdminBundle\Form\MediaAdminType;
use Cz\AdminBundle\Form\CarrouselNameType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
class CarrouselType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('format',ChoiceType::class, array(
'choices' => array(
1 => 'Pleine Larger',
0 => 'Normal'
)))
->add('image',new MediaAdminType())
->add('locale', new CarrouselNameType())
->add('fleche',CheckboxType::class)
;
}
/**
* Sets the default options for this type.
*
* @param OptionsResolver $resolver The resolver for the options.
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Cz\AdminBundle\Entity\Carrousel'
));
}
/**
* @return string
*/
public function getName()
{
return 'cz_adminbundle_carrousel';
}
}
<?php
namespace Cz\AdminBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
class CarrouselNameType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title',TextType::class
)
->add('locale',ChoiceType::class, array(
'label'=> false,
'choices' => array(
'fr' => 'FRANCAIS',
'en' => 'ENGLAIS'
)))
;
}
/**
* Sets the default options for this type.
*
* @param OptionsResolver $resolver The resolver for the options.
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Cz\AdminBundle\Entity\CarrouselName'
));
}
/**
* @return string
*/
public function getName()
{
return 'cz_adminbundle_carrousel';
}
}
merci d'avance pour votre aide