12.07.2015 Views

My first symfony project - Mesurex

My first symfony project - Mesurex

My first symfony project - Mesurex

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>My</strong> <strong>first</strong> <strong>symfony</strong> <strong>project</strong> 11This is getting good.Find more about the naming conventions 13 linking an action to a template.Add a record relative to another tableCurrently you can’t add comments to posts directly; if you edit a post, you have to go to thecomments editing section, create a new one, then select the post you want to comment onusing the drop-down menu. The screen looks like this:It would be better if there was a link on each post editing page to go straight to the commentediting facility, so let’s arrange that <strong>first</strong>. In the sf_sandbox/apps/frontend/modules/post/templates/showSuccess.php template, add this line at the bottom:Listing1-26The link_to() helper creates a hyperlink pointing to the edit action of the commentmodule, so you can add a comment directly from the post details page. At the moment,however, the comments edit page still offers a form element to select which post to relate acomment to. This would be best replaced by a hidden field (containing the post primary key)if the comments edit page URL is called specifying that key.In <strong>symfony</strong>, forms are managed by classes. So, let’s edit the BlogCommentForm class to makeour changes. The file is located under the sf_sandbox/lib/form/ directory:class BlogCommentForm extends BaseBlogCommentForm{/*** Configure method, called when the form is instantiated*/public function configure(){$this->widgetSchema['blog_post_id'] = new sfWidgetFormInputHidden();}}Listing1-2713. http://www.<strong>symfony</strong>-<strong>project</strong>.org/book/1_2/07-Inside-the-View-Layer----------------- Brought to you by

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!