Skip to content

Commit

Permalink
Added ability to disable form tabs closes #951
Browse files Browse the repository at this point in the history
  • Loading branch information
isometriks committed Oct 17, 2014
1 parent 850a4ea commit 6708dba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions Form/Extension/TabbedFormTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function finishView(FormView $view, FormInterface $form, array $options)
'label' => $child->vars['label'],
'icon' => $child->vars['icon'],
'active' => false,
'disabled' => $child->vars['disabled'],
'translation_domain' => $child->vars['translation_domain'],
);

Expand Down
2 changes: 2 additions & 0 deletions Form/Type/TabType.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
$resolver->setDefaults(array(
'icon' => null,
'error_icon' => 'remove-sign',
'disabled' => false,
));
}

Expand All @@ -42,6 +43,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)
$view->vars['valid'] = $valid = !$form->isSubmitted() || $form->isValid();
$view->vars['icon'] = $valid ? $options['icon'] : $options['error_icon'];
$view->vars['tab_active'] = false;
$view->vars['disabled'] = $options['disabled'];

$view->parent->vars['tabbed'] = true;
}
Expand Down
3 changes: 2 additions & 1 deletion Resources/views/Form/fields.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@
{% spaceless %}
<ul class="{{ form.vars.attr.class }}">
{% for tab in form.vars.tabs %}
<li{% if tab.active %} class="active"{% endif %}>
{% set class = (tab.active ? 'active ' : '') ~ (tab.disabled ? 'disabled' : '') %}
<li{% if class|trim is not empty %} class="{{ class }}"{% endif %}>
<a data-toggle="tab" href="#{{ tab.id }}">
{% if tab.icon %}{{ mopa_bootstrap_icon(tab.icon) }}{% endif %}
{{ tab.label|trans({}, tab.translation_domain) }}
Expand Down

0 comments on commit 6708dba

Please sign in to comment.