Skip to content

Commit e3147da

Browse files
committed
[symfony#2675] Updating chnages to the registration chapter
1) Added XML and PHP routing 2) Removed database creation step and re-worded items
1 parent b0de5d8 commit e3147da

File tree

1 file changed

+50
-14
lines changed

1 file changed

+50
-14
lines changed

cookbook/doctrine/registration_form.rst

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -284,27 +284,63 @@ the validation and saves the data into the database::
284284
Add New Routes
285285
--------------
286286

287-
Next, update your routes
287+
Next, update your routes. If you're placing your routes inside your bundle
288+
(as shown here), don't forget to make sure that the routing file is being
289+
:ref:`imported<routing-include-external-resources>`.
288290

289-
.. code-block:: yml
291+
.. configuration-block::
290292

291-
register:
292-
pattern: /register
293-
defaults: { _controller: AcmeAccountBundle:Account:register }
293+
.. code-block:: yml
294+
295+
# src/Acme/AccountBundle/Resources/config/routing.yml
296+
account_register:
297+
pattern: /register
298+
defaults: { _controller: AcmeAccountBundle:Account:register }
294299
295-
create:
296-
pattern: /create
297-
defaults: { _controller: AcmeAccountBundle:Account:create }
300+
account_create:
301+
pattern: /register/create
302+
defaults: { _controller: AcmeAccountBundle:Account:create }
298303
299-
Run Doctrine Commands
300-
---------------------
304+
.. code-block:: xml
305+
306+
<!-- src/Acme/AccountBundle/Resources/config/routing.xml -->
307+
<?xml version="1.0" encoding="UTF-8" ?>
308+
<routes xmlns="http://symfony.com/schema/routing"
309+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
310+
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
311+
312+
<route id="account_register" path="/register">
313+
<default key="_controller">AcmeAccountBundle:Account:register</default>
314+
</route>
315+
316+
<route id="account_create" path="/register/create">
317+
<default key="_controller">AcmeAccountBundle:Account:create</default>
318+
</route>
319+
</routes>
301320
302-
Finally, generate your entities and schema
321+
.. code-block:: php
322+
323+
// src/Acme/AccountBundle/Resources/config/routing.php
324+
use Symfony\Component\Routing\RouteCollection;
325+
use Symfony\Component\Routing\Route;
326+
327+
$collection = new RouteCollection();
328+
$collection->add('account_register', new Route('/register', array(
329+
'_controller' => 'AcmeAccountBundle:Account:register',
330+
)));
331+
$collection->add('account_create', new Route('/register/create', array(
332+
'_controller' => 'AcmeAccountBundle:Account:create',
333+
)));
334+
335+
return $collection;
336+
337+
Update your Database Schema
338+
---------------------------
303339

304-
.. code-block::
340+
Of course, since you've added a ``User`` entity during this tutorial, make
341+
sure that your database schema has been updated properly:
305342

306-
php app/console doctrine:database:create
307-
php app/console doctrine:schema:update --force
343+
$ php app/console doctrine:schema:update --force
308344

309345
That's it! Your form now validates, and allows you to save the ``User``
310346
object to the database. The extra ``terms`` checkbox on the ``Registration``

0 commit comments

Comments
 (0)