formhelper - How to iterate through object array with form helpes in cakephp? -


i have object curatedpage property pagename.

i creating array of curatedpage objects in controller , setting view this:

$this->set('curatedpages', $curatedpages); 

in view creating dropdown of page names this:

$pagenames = array(); foreach($curatedpages $curatedpage) {     array_push($pagenames, $curatedpage->getpagename()); } echo $this->form->input('curatedpage', array('options' => $pagenames)); 

is there way in cakephp allow me pass array of curatedpage objects form->input(...) instead of creating array of scalar values.

i'm not sure expect form helper in case. however, depending on php version (>= 5.2.0 required) magic __tostring() method might it. if implement return pagename, end same result posted snippet, ie numerical indexed (the value attribute) html option list page names labels.

however, implementing purpose in specific view seems wrong me, you're better of utilizing custom helper, or @brianglaz suggested prepare data in controller.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -