Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Nov 27, 2020. It is now read-only.

Commit b7f1ed1

Browse files
committed
playground for symfony/symfony#14165
1 parent 707ec3c commit b7f1ed1

File tree

7 files changed

+79
-75
lines changed

7 files changed

+79
-75
lines changed

app/AppKernel.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public function registerBundles()
2323
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
2424
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
2525
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
26-
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
2726
}
2827

2928
return $bundles;
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{% extends 'base.html.twig' %}
22

33
{% block body %}
4-
Homepage.
4+
{{ form_start(form, {'attr': {'novalidate': 'novalidate'}}) }}
5+
{{ form_widget(form) }}
6+
<button type="submit">come on, hit me!</button>
7+
{{ form_end(form) }}
58
{% endblock %}

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"require": {
1010
"php": ">=5.3.3",
11-
"symfony/symfony": "2.7.x-dev",
11+
"symfony/symfony": "2.7.x-dev#ef886548a0b6d1467876a60ef8f2c0f1e5a3ac3c",
1212
"doctrine/orm": "~2.2,>=2.2.3,<2.5",
1313
"doctrine/dbal": "<2.5",
1414
"doctrine/doctrine-bundle": "~1.4",
@@ -47,7 +47,8 @@
4747
]
4848
},
4949
"config": {
50-
"bin-dir": "bin"
50+
"bin-dir": "bin",
51+
"notify-on-install": false
5152
},
5253
"extra": {
5354
"symfony-app-dir": "app",

composer.lock

Lines changed: 5 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1-
<?php
2-
3-
namespace AppBundle\Controller;
4-
5-
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6-
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7-
8-
class DefaultController extends Controller
9-
{
10-
/**
11-
* @Route("/app/example", name="homepage")
12-
*/
13-
public function indexAction()
14-
{
15-
return $this->render('default/index.html.twig');
16-
}
1+
<?php
2+
3+
namespace AppBundle\Controller;
4+
5+
use AppBundle\Entity\Vehicle;
6+
use AppBundle\Form\CreateVehicleForm;
7+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
8+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
9+
use Symfony\Component\HttpFoundation\Request;
10+
11+
class DefaultController extends Controller {
12+
13+
/**
14+
* @Route("/", name="homepage")
15+
*/
16+
public function indexAction(Request $request) {
17+
$form = $this->createForm(new CreateVehicleForm(), new Vehicle());
18+
$form->handleRequest($request);
19+
20+
return $this->render('default/index.html.twig', array(
21+
'form' => $form->createView(),
22+
));
23+
}
24+
1725
}

src/AppBundle/Entity/Vehicle.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace AppBundle\Entity;
4+
5+
use Symfony\Component\Validator\Constraints as Assert;
6+
7+
class Vehicle {
8+
9+
/**
10+
* @var integer
11+
* @Assert\NotBlank
12+
*/
13+
public $numberOfWheels;
14+
15+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace AppBundle\Form;
4+
5+
use Symfony\Component\Form\AbstractType;
6+
use Symfony\Component\Form\FormBuilderInterface;
7+
8+
class CreateVehicleForm extends AbstractType {
9+
10+
/**
11+
* {@inheritDoc}
12+
*/
13+
public function buildForm(FormBuilderInterface $builder, array $options) {
14+
$choices = array(2, 4);
15+
$builder->add('numberOfWheels', 'choice', array(
16+
'choices' => array_combine($choices, $choices),
17+
'empty_value' => '',
18+
));
19+
}
20+
21+
/**
22+
* {@inheritDoc}
23+
*/
24+
public function getName() {
25+
return 'createVehicle';
26+
}
27+
28+
}

0 commit comments

Comments
 (0)