mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-23 16:13:50 +00:00
add testing for customfield, correcting request injection
This commit is contained in:
@@ -18,6 +18,7 @@ use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Chill\CustomFieldsBundle\Form\AdressType;
|
||||
use Chill\CustomFieldsBundle\Service\CustomFieldProvider;
|
||||
use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldDataTransformer;
|
||||
use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
|
||||
|
||||
class CustomFieldType extends AbstractType
|
||||
{
|
||||
@@ -44,68 +45,19 @@ class CustomFieldType extends AbstractType
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$customFields = $this->om
|
||||
->getRepository('ChillCustomFieldsBundle:CustomField')
|
||||
->findAll();
|
||||
|
||||
foreach ($customFields as $cf) {
|
||||
|
||||
//$builder->add(
|
||||
//$builder->create(
|
||||
//$cf->getSlug(),
|
||||
$this->customFieldCompiler
|
||||
->getCustomFieldByType($cf->getType())
|
||||
->buildForm($builder, $cf);
|
||||
/* )
|
||||
->addModelTransformer(new CustomFieldDataTransformer(
|
||||
$this->customFieldCompiler
|
||||
->getCustomFieldByType($cf->getType()),
|
||||
$cf)
|
||||
)*/
|
||||
//);
|
||||
|
||||
// if($cf->getType() === 'ManyToOne(Adress)') {
|
||||
// $builder->add($cf->getLabel(), 'entity', array(
|
||||
// 'class' => 'ChillCustomFieldsBundle:Adress',
|
||||
// 'property' => 'data'
|
||||
// ));
|
||||
// } else if ($cf->getType() === 'ManyToOnePersist(Adress)') {
|
||||
// $builder->add($cf->getLabel(), new AdressType());
|
||||
// } else if($cf->getType() === 'ManyToMany(Adress)') {
|
||||
//
|
||||
// $adress = $this->om
|
||||
// ->getRepository('ChillCustomFieldsBundle:Adress')
|
||||
// ->findAll();
|
||||
//
|
||||
// $adressId = array_map(
|
||||
// function($e) { return $e->getId(); },
|
||||
// $adress);
|
||||
//
|
||||
// $adressLabel = array_map(
|
||||
// function($e) { return (string) $e; },
|
||||
// $adress);
|
||||
//
|
||||
// $addressChoices = array_combine($adressId, $adressLabel);
|
||||
//
|
||||
//
|
||||
// $builder->add($cf->getLabel(), 'choice', array(
|
||||
// 'choices' => $addressChoices,
|
||||
// 'multiple' => true
|
||||
// ));
|
||||
// }
|
||||
// else {
|
||||
// $builder->add($cf->getLabel(), $cf->getType());
|
||||
// }
|
||||
foreach ($options['group']->getCustomFields() as $cf) {
|
||||
$this->customFieldCompiler
|
||||
->getCustomFieldByType($cf->getType())
|
||||
->buildForm($builder, $cf);
|
||||
}
|
||||
|
||||
//$builder->addViewTransformer(new JsonCustomFieldToArrayTransformer($this->om));
|
||||
}
|
||||
|
||||
public function setDefaultOptions(\Symfony\Component\OptionsResolver\OptionsResolverInterface $resolver)
|
||||
{
|
||||
$resolver
|
||||
//->addAllowedTypes(array('context' => 'string'))
|
||||
//->setRequired(array('context'))
|
||||
->setRequired(array('group'))
|
||||
->addAllowedTypes(array('group' =>
|
||||
array('Chill\CustomFieldsBundle\Entity\CustomFieldsGroup')))
|
||||
;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user