Skip to content

Commit

Permalink
Merge pull request #29 from Padam87/gh-14-definition-options
Browse files Browse the repository at this point in the history
Readded option type
  • Loading branch information
Padam87 committed Apr 23, 2015
2 parents 8fb84af + 99ab788 commit e7836bd
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 e7836bd

Please sign in to comment.