Skip to content

Commit

Permalink
Merge pull request #1 from hshn/form-type-strictness-option
Browse files Browse the repository at this point in the history
Introduce strict option to Base64EncodedFileType
  • Loading branch information
hshn committed Nov 3, 2015
2 parents 2704c3f + 8cb9bfc commit 52eb2ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"symfony/http-foundation": "~2.4"
},
"require-dev": {
"symfony/form": "~2.4"
"symfony/form": "~2.7"
},
"suggest": {
"symfony/form": "to use base64_encoded_file type"
Expand Down
8 changes: 5 additions & 3 deletions src/Form/Type/Base64EncodedFileType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Hshn\Base64EncodedFile\Form\DataTransformer\FileToBase64EncodedStringTransformer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;


/**
Expand All @@ -19,21 +19,23 @@ class Base64EncodedFileType extends AbstractType
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addViewTransformer(new FileToBase64EncodedStringTransformer());
$builder->addViewTransformer(new FileToBase64EncodedStringTransformer($options['strict_decode']));
}

/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setDefaults([
'compound' => false,
'data_class' => null,
'empty_data' => null,
'multiple' => false,
'strict_decode' => true,
])
->setAllowedTypes('strict_decode', 'boolean')
;
}

Expand Down

0 comments on commit 52eb2ea

Please sign in to comment.