From ca38509fde90967fadd80f79d0ab7a62ff8bd928 Mon Sep 17 00:00:00 2001 From: hhamon Date: Fri, 4 Feb 2011 09:30:53 +0100 Subject: [PATCH] [cache, form] fixed minor typo and twig sample snippets --- guides/cache/http.rst | 4 ++-- guides/forms/overview.rst | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/guides/cache/http.rst b/guides/cache/http.rst index 351f14fb93b..45541771bf5 100644 --- a/guides/cache/http.rst +++ b/guides/cache/http.rst @@ -58,7 +58,7 @@ header when none is set by the developer by following these rules: * If ``Cache-Control`` is empty, its value is set to ``private, max-age=0, must-revalidate``; -* But if at least one ``Cache-Control`` directive is set, and no 'public' or +* But if at least one ``Cache-Control`` directive is set, and no ``public`` or ``private`` directives have been explicitly added, Symfony2 adds the ``private`` directive automatically (except when ``s-maxage`` is set). @@ -183,7 +183,7 @@ which the response is considered stale." The ``Expires`` header can be set with the ``setExpires()`` Response method. It takes a ``DateTime`` instance as an argument:: - $date = new DateTime(); + $date = new \DateTime(); $date->modify('+600 seconds'); $response->setExpires($date); diff --git a/guides/forms/overview.rst b/guides/forms/overview.rst index 9234508a651..013779baaa9 100755 --- a/guides/forms/overview.rst +++ b/guides/forms/overview.rst @@ -87,14 +87,14 @@ The standard pattern for using a form in a controller looks like this: // src/Sensio/HelloBundle/Controller/HelloController.php public function contactAction() { - $contactRequest = new ContactRequest(); - $form = ContactForm::create($this->get('form.context')); + $contactRequest = new ContactRequest($this->get('mailer')); + $form = ContactForm::create($this->get('form.context'), 'contact'); // If a POST request, write submitted data into $contactRequest - // and validate it + // and validate them $form->bind($this->get('request'), $contactRequest); - // If the form has been submitted and validates... + // If the form has been submitted and validated... if ($form->isValid()) { $contactRequest->send(); } @@ -301,11 +301,13 @@ of the form. # src/Sensio/HelloBundle/Resources/views/Hello/contact.html.twig {% extends 'HelloBundle::layout.html.twig' %} + {% block content %}
{{ form_field(form) }}
+ {% endblock %} Customizing the HTML Output --------------------------- @@ -318,20 +320,24 @@ can do so by using the other built-in form rendering helpers. # src/Sensio/HelloBundle/Resources/views/Hello/contact.html.twig {% extends 'HelloBundle::layout.html.twig' %} + {% block content %}
{{ form_errors(form) }} {% for field in form %} + {% if not field.ishidden %}
{{ form_errors(field) }} {{ form_label(field) }} {{ form_field(field) }}
+ {% endif %} {% endfor %} {{ form_hidden(form) }}
+ {% endblock %} Symfony2 comes with the following helpers: