/** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $fileFormat = new fileFormat(); $iconChoice = $fileFormat->getTypeIcons(); $builder->add('nom', 'text', array('label' => 'form.nom', 'required' => true))->add('icon', 'choice', array('label' => 'form.icone', 'required' => true, 'multiple' => false, 'expanded' => false, 'choices' => $iconChoice))->add('contentType', 'text', array('label' => 'Content Type'))->add('enabled', 'checkbox', array('label' => 'actif', 'required' => false)); // ajoute les valeurs hidden, passés en paramètre $builder = $this->addHiddenValues($builder); // AJOUT SUBMIT $builder->add('submit', 'submit', array('label' => 'form.enregistrer', 'attr' => array('class' => "btn btn-md btn-block btn-info"))); }
/** * Crée un nouveau format de fichier * @param string $contentType * @param string $nom * @param boolean $enable * @return fileFormat */ public function createNewFormat($contentType, $nom = null, $enable = true) { $newFormat = new fileFormat(); $newFormat->setEnabled($enable); $newFormat->setContentType($contentType); if (!is_string($nom)) { $nom = $contentType; } $newFormat->setNom($nom); $this->em->persist($newFormat); $this->em->flush(); return $newFormat; }
/** * Set format * @param fileFormat $format * @return media */ public function setFormat(fileFormat $format = null) { $this->format = $format; if ($format != null) { $format->addMedia_reverse($this); } else { $format->removeMedia_reverse($this); } return $this; }