-
-
Save lastk/80b347dda918c7eb9c2b566e9d31932a to your computer and use it in GitHub Desktop.
Symfony TextTypeExtension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
form.extension.text_type: | |
class: PlatformBundle\Form\Extension\TextTypeExtension | |
tags: | |
- { name: form.type_extension, extended_type: Symfony\Component\Form\Extension\Core\Type\TextType } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace PlatformBundle\Form\Extension; | |
use Symfony\Component\Form\AbstractTypeExtension; | |
use Symfony\Component\Form\Extension\Core\Type\TextType; | |
use Symfony\Component\Form\FormInterface; | |
use Symfony\Component\Form\FormView; | |
use Symfony\Component\OptionsResolver\OptionsResolver; | |
class TextTypeExtension extends AbstractTypeExtension | |
{ | |
public function getExtendedType() | |
{ | |
return TextType::class; | |
} | |
public function buildView(FormView $view, FormInterface $form, array $options) | |
{ | |
if (array_key_exists('type', $options)) { | |
$view->vars['type'] = $options['type']; | |
} | |
} | |
public function configureOptions(OptionsResolver $resolver) | |
{ | |
$resolver->setDefined('type'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment