Code snippets for symfony 1.x

Navigation

Refine Tags

Snippets tagged "objecthelper"

Specify another method than toString() to call in object_select_tag

In an object_select_tag, the toString() method is automacally called to display the object in the list.

Sometimes, you can't use the same method for diffrent list on the same objects, so you have to specify wich method to call.

So this is the tip : 'text_method' => 'theMethodToCall'

object_select_tag($my_object, 'myMethod', array (
  'related_class' => 'MyObjectClass',
  'text_method' => 'getCompleteDescription'
))
by whoknows on 2007-07-10, tagged helper  objecthelper 
(1 comment)

Saving records w/ Doctrine from a form using object helpers

// This is meant to be in actions.class.php as one of your actions. // Note how it redirects to your view action after saving.

public function executeSave() { $req = $this->getRequest();

$q = new Doctrine_Query();
$user = $q->from('UserInfo')->where('id = ?',$this->getRequestParameter('id'))->execute()->getFirst();
 
$user->merge($req->getParameterHolder()->getAll());
$user->save();
 
$this->redirect('user/view?did=save&id='.$user->id);

}

by whoknows on 2007-06-12, tagged doctrine  objecthelper  save