Skip to content
This repository was archived by the owner on Feb 16, 2021. It is now read-only.

Commit d5bd771

Browse files
committed
Merge pull request #15 from carakas/form-button-with-icon-example
Add button icons example to the bundle
2 parents 02bd45d + 46fb824 commit d5bd771

File tree

6 files changed

+68
-1
lines changed

6 files changed

+68
-1
lines changed

Controller/TutorialController.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace SumoCoders\FrameworkExampleBundle\Controller;
44

55
use Knp\Menu\MenuItem;
6+
use SumoCoders\FrameworkExampleBundle\Form\Type\ButtonIconType;
67
use SumoCoders\FrameworkExampleBundle\Form\Type\CollectionsType;
78
use SumoCoders\FrameworkExampleBundle\Form\Type\DatePickerType;
89
use SumoCoders\FrameworkExampleBundle\Form\Type\LabelsType;
@@ -33,7 +34,20 @@ public function datePickerAction()
3334
*/
3435
public function labelsAction()
3536
{
36-
$form = $this->createForm(new LabelsType);
37+
$form = $this->createForm(new LabelsType());
38+
39+
return array(
40+
'form' => $form->createView(),
41+
);
42+
}
43+
44+
/**
45+
* @Route("/tutorial/button-icons")
46+
* @Template()
47+
*/
48+
public function buttonIconsAction()
49+
{
50+
$form = $this->createForm(new ButtonIconType());
3751

3852
return array(
3953
'form' => $form->createView(),

EventListener/MenuListener.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public function onConfigureMenu(ConfigureMenuEvent $event)
7676
),
7777
'example.menu.datepicker' => 'sumocoders_frameworkexample_tutorial_datepicker',
7878
'example.menu.labels' => 'sumocoders_frameworkexample_tutorial_labels',
79+
'example.menu.buttonIcons' => 'sumocoders_frameworkexample_tutorial_buttonicons',
7980
'example.menu.statistics' => 'sumocoders_frameworkexample_tutorial_statistics',
8081
'example.menu.customBreadCrumb' => 'sumocoders_frameworkexample_tutorial_custombreadcrumb',
8182
'example.menu.collections' => 'sumocoders_frameworkexample_tutorial_collections',

Form/Type/ButtonIconType.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace SumoCoders\FrameworkExampleBundle\Form\Type;
4+
5+
use Symfony\Component\Form\AbstractType;
6+
use Symfony\Component\Form\FormBuilderInterface;
7+
8+
class ButtonIconType extends AbstractType
9+
{
10+
/**
11+
* {@inheritdoc}
12+
*/
13+
public function buildForm(FormBuilderInterface $builder, array $options)
14+
{
15+
$builder->add(
16+
'example',
17+
'submit',
18+
[
19+
'label' => 'Bug',
20+
'icon' => 'fa fa-bug',
21+
'attr' => [
22+
'class' => 'btn btn-large btn-default btn-block',
23+
],
24+
]
25+
);
26+
}
27+
28+
/**
29+
* {@inheritdoc}
30+
*/
31+
public function getName()
32+
{
33+
return 'buttonIcons';
34+
}
35+
}

Resources/translations/messages.en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ example:
66
datepicker: datepickers
77
hello: hello %name%
88
labels: labels
9+
buttonIcons: button icons
910

1011
menu:
1112
bootstrap: bootstrap
@@ -17,6 +18,7 @@ example:
1718
labels: labels
1819
tutorials: tutorials
1920
statistics: statistics
21+
buttonIcons: button icons
2022

2123
datePicker:
2224
birthday.example: birthday

Resources/translations/messages.nl.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ example:
66
datepicker: date pickers
77
hello: hallo %name%
88
labels: labels
9+
buttonIcons: knop iconen
910

1011
menu:
1112
bootstrap: bootstrap
@@ -15,6 +16,7 @@ example:
1516
examples: voorbeelden
1617
hello: hallo
1718
labels: labels
19+
buttonIcons: knop iconen
1820
tutorials: howto's
1921
statistics: statistics
2022

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{% extends '::base.html.twig' %}
2+
3+
{% block header_title %}
4+
<h2>
5+
{{ 'example.header.title.buttonIcons'|trans|capitalize }}
6+
</h2>
7+
{% endblock %}
8+
9+
{% block main %}
10+
{{ form_start(form) }}
11+
{{ form_rest(form) }}
12+
{{ form_end(form) }}
13+
{% endblock %}

0 commit comments

Comments
 (0)