Skip to content

Commit

Permalink
Readded option type
Browse files Browse the repository at this point in the history
  • Loading branch information
Padam87 committed Apr 23, 2015
1 parent 8fb84af commit 99ab788
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Form/DefinitionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'radio' => 'Radio'
)
));
$builder->add('options', 'collection', array(
'type' => new OptionType(),
'allow_add' => true,
'allow_delete' => true,
'prototype' => true,
'by_reference' => false,
'options' => array(),
));
$builder->add('unit', 'text', array(
'required' => false
));
Expand Down
27 changes: 27 additions & 0 deletions Form/OptionType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Padam87\AttributeBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class OptionType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('name', 'text', []);
}

public function getName()
{
return 'attribute_option';
}

public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Padam87\AttributeBundle\Entity\Option',
));
}
}

0 comments on commit 99ab788

Please sign in to comment.