-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Carlo Forghieri
committed
Jun 9, 2016
1 parent
89ee3d5
commit f6a4a12
Showing
9 changed files
with
226 additions
and
58 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,55 @@ | ||
<?php | ||
namespace Mopa\Bundle\BootstrapBundle\Form\Extension; | ||
|
||
use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
use Symfony\Component\Form\AbstractTypeExtension; | ||
use Symfony\Component\Form\FormInterface; | ||
use Symfony\Component\Form\FormView; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
|
||
class ErrorTypeFormTypeExtension extends AbstractTypeExtension | ||
{ | ||
protected $error_type; | ||
protected $errorType; | ||
|
||
public function __construct(array $options) | ||
{ | ||
$this->error_type = $options['error_type']; | ||
$this->errorType = $options['error_type']; | ||
} | ||
public function buildView(FormView $view, FormInterface $form, array $options) | ||
{ | ||
$view->vars['error_type'] = $options['error_type']; | ||
$view->vars['error_delay'] = $options['error_delay']; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @deprecated Remove it when bumping requirements to SF 2.7+ | ||
*/ | ||
public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
{ | ||
$this->configureOptions($resolver); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function configureOptions(OptionsResolver $resolver) | ||
{ | ||
$resolver->setDefaults(array( | ||
'error_type' => $this->error_type, | ||
'error_delay'=> false | ||
)); | ||
'error_type' => $this->errorType, | ||
'error_delay' => false, | ||
)); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getExtendedType() | ||
{ | ||
return 'form'; | ||
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') | ||
? 'Symfony\Component\Form\Extension\Core\Type\FormType' | ||
: 'form' // SF <2.8 BC | ||
; | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.