Skip to content

Commit

Permalink
renaming button extensions new options for better clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
derpue committed Aug 20, 2014
1 parent 0c28d92 commit 6f1d0e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Form/Extension/ButtonTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ class ButtonTypeExtension extends AbstractTypeExtension
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars['buttonclass'] = $form->getConfig()->getOption('buttonclass');
$view->vars['asatag'] = $form->getConfig()->getOption('asatag');
$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('buttonclass', 'asatag'));
$resolver->setOptional(array('button_class', 'as_link'));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions Resources/views/Form/bootstrap.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -502,11 +502,11 @@
{% set label = name|humanize %}
{% endif %}
{% if type is defined and type == 'submit' %}
{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' btn btn-'~buttonclass|default('primary'))|trim }) %}
{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' btn btn-'~button_class|default('primary'))|trim }) %}
{% else %}
{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' btn btn-'~buttonclass|default('default'))|trim }) %}
{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' btn btn-'~button_class|default('default'))|trim }) %}
{% endif %}
{% if asatag is defined and asatag == true %}
{% if as_link is defined and as_link == true %}
<a {{ block('button_attributes') }}>{% if attr.icon is defined and attr.icon != '' %}{{ icon(attr.icon) }}{% endif %}{{ label|trans({}, translation_domain) }}</a>
{% else %}
<button type="{{ type|default('button') }}" {{ block('button_attributes') }}>{% if attr.icon is defined and attr.icon != '' %}{{ icon(attr.icon) }}{% endif %}{{ label|trans({}, translation_domain) }}</button>
Expand Down

0 comments on commit 6f1d0e4

Please sign in to comment.