-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #286 from derpue/form_actions_patch
Form actions patch
- Loading branch information
Showing
3 changed files
with
60 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Braincrafted\Bundle\BootstrapBundle\Form\Extension; | ||
|
||
use Symfony\Component\Form\AbstractTypeExtension; | ||
use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
use Symfony\Component\Form\FormView; | ||
use Symfony\Component\Form\FormInterface; | ||
|
||
/** | ||
* FormControlStaticType | ||
* | ||
* @package BraincraftedBootstrapBundle | ||
* @subpackage Form | ||
* @author André Püschel <[email protected]> | ||
* @copyright 2014 André Püschel | ||
* @license http://opensource.org/licenses/MIT The MIT License | ||
* @link http://bootstrap.braincrafted.com Bootstrap for Symfony2 | ||
*/ | ||
class ButtonTypeExtension extends AbstractTypeExtension | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function buildView(FormView $view, FormInterface $form, array $options) | ||
{ | ||
$view->vars['button_class'] = $form->getConfig()->getOption('button_class'); | ||
$view->vars['as_link'] = $form->getConfig()->getOption('as_link'); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
{ | ||
$resolver->setOptional(array('button_class', 'as_link')); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getExtendedType() | ||
{ | ||
return 'button'; | ||
} | ||
} |
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