symfony1 - Symfony generation -


when generate module in symfony 1.4, creates (for example) 'new' , 'create' methods this:

public function executenew(sfwebrequest $request) {   $this->form = new someform(); }  public function executecreate(sfwebrequest $request) {   $this->forward404unless($request->ismethod(sfrequest::post));    $this->form = new someform();   $form->bind($request->getparameter($form->getname()), $request->getfiles($form->getname()));   if ($form->isvalid())   {     $res_object = $form->save();     $this->redirect('results_show', $res_object);   }    $this->settemplate('new'); } 

with --non-verbose-templates generates code below (i modified show creation part):

public function executenew(sfwebrequest $request) {   $this->forward404unless($request->ismethod(sfrequest::post));    $this->form = new someform();   if ($request->ismethod(sfrequest::post)) {     $form->bind($request->getparameter($form->getname()), $request->getfiles($form->getname()));     if ($form->isvalid())     {       $res_object = $form->save();       $this->redirect('results_show', $res_object);     }   } } 

what's reason of such default generation? think method below more compact, adds lesser routes , actions , doesn't change url first , next (if there errors) form displaying. default generation method should best or usable. so, guys sensio labs know, don't?

the first template better suited building restful application symfony.

if want use clever sfobjectroutecollection class creating collection of routes both executenew , executecreate methods expected.

sfobjectroutecollection default creates routes following actions:

list, new, create, edit, update, delete, , show.

you correct preferred template has 1 url not problem if using doctrine/propel forms , helper form_tag_for(). helper takes form , name of route collection arguments figures out the correct route/url use collection.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -