Skip to content

Commit

Permalink
Make amount and currency type configurable.
Browse files Browse the repository at this point in the history
  • Loading branch information
tautelis committed Feb 3, 2017
1 parent 2be1df3 commit 0ee3646
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Form/Type/MoneyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public function __construct($decimals)
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('tbbc_amount', 'Symfony\Component\Form\Extension\Core\Type\TextType')
->add('tbbc_currency', $options['currency_type'])
->add('tbbc_amount', 'Symfony\Component\Form\Extension\Core\Type\TextType', $options['tbbc_amount_options'])
->add('tbbc_currency', $options['currency_type'], $options['tbbc_currency_options'])
->addModelTransformer(
new MoneyToArrayTransformer($this->decimals)
);
Expand All @@ -47,6 +47,8 @@ public function configureOptions(OptionsResolver $resolver)
->setDefaults(array(
'data_class' => null,
'currency_type' => 'Tbbc\MoneyBundle\Form\Type\CurrencyType',
'tbbc_amount_options' => array(),
'tbbc_currency_options' => array(),
))
->setAllowedTypes(
'currency_type',
Expand Down
2 changes: 1 addition & 1 deletion Form/Type/SimpleMoneyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(PairManagerInterface $pairManager, $decimals)
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('tbbc_amount', 'Symfony\Component\Form\Extension\Core\Type\TextType')
->add('tbbc_amount', 'Symfony\Component\Form\Extension\Core\Type\TextType', $options['tbbc_amount_options'])
->addModelTransformer(
new SimpleMoneyToArrayTransformer($this->pairManager, $this->decimals)
);
Expand Down

0 comments on commit 0ee3646

Please sign in to comment.