Re: [fw-general] Populating Zend_Form_Element_Select from database example

2009-02-01 Thread Deepak Shrestha
> Yes, add a setter method for attaching the model to the form and then do > this in the controller. The form will then have access to the model to > retrieve any data it needs. > > You can also populate the element directly in your controller by retrieving > it from the form and manipulating it e.

Re: [fw-general] Populating Zend_Form_Element_Select from database example

2009-01-31 Thread gerardroche
ok, sorry. >1. I am going to manipulate the model from the form class itself (is >this true?) Yes. >>a) Do I need to declare global variable in my form class plus getter, >>setter methods so that Controller can set that variable through those >>methods and I can use the data provided in that v

Re: [fw-general] Populating Zend_Form_Element_Select from database example

2009-01-31 Thread Deepak Shrestha
On Sun, Feb 1, 2009 at 12:37 AM, Daniel Latter wrote: > a) Do I need to declare global variable in my form class plus getter, > setter methods so that Controller can set that variable through those > methods and I can use the data provided in that variable? > > yes. so what is the use of populate

Fwd: [fw-general] Populating Zend_Form_Element_Select from database example

2009-01-31 Thread Daniel Latter
a) Do I need to declare global variable in my form class plus getter, setter methods so that Controller can set that variable through those methods and I can use the data provided in that variable? yes. Thank You Daniel Latter 2009/1/31 Deepak Shrestha : > On Sat, Jan 31, 2009 at 11:46 PM, ger

Re: [fw-general] Populating Zend_Form_Element_Select from database example

2009-01-31 Thread Deepak Shrestha
On Sat, Jan 31, 2009 at 11:46 PM, gerardroche wrote: > > you keep moving the goal posts. > > put this in your form, to the letter: > > $location= New Zend_Form_Element_Select('location'); > $location->setLabel('*Location:'); > $location->setMultiOptions(array('location1' => 'location1', 'location2

Re: [fw-general] Populating Zend_Form_Element_Select from database example

2009-01-31 Thread gerardroche
you keep moving the goal posts. put this in your form, to the letter: $location= New Zend_Form_Element_Select('location'); $location->setLabel('*Location:'); $location->setMultiOptions(array('location1' => 'location1', 'location2' => 'location2')); And in your controller: $data = array('loca

Re: [fw-general] Populating Zend_Form_Element_Select from database example

2009-01-31 Thread gerardroche
yes. If it's still throwing errors post the error message. Also what version of ZF are you using? Deepak Shrestha wrote: > >> no. >> >> Change "in my controller" to the following >> >> in my controller >> == >> $data = array('location' => 'location1'); >> $form= $this->_getTe

Re: [fw-general] Populating Zend_Form_Element_Select from database example

2009-01-31 Thread Daniel Latter
The following is from an earlier post and this is what is throwing the error, as you can see there is a reference to $this->data? foreach($this->data as $loc)<< is $data passed from controller directly accessed here? { $adlocation->addMultiOption($loc, $loc); } Thank You Daniel Latter

Re: [fw-general] Populating Zend_Form_Element_Select from database example

2009-01-31 Thread gerardroche
what has $this->data got to do with it? There is no $data property in the Zend_Form class. Daniel Latter-2 wrote: > > I still don't see where $this->data is set? in the form class for you to > use it? > > what do you think gerardroche? > > Thank You > Daniel Latter > > > > 2009/1/31 ger

Re: [fw-general] Populating Zend_Form_Element_Select from database example

2009-01-31 Thread Deepak Shrestha
> no. > > Change "in my controller" to the following > > in my controller > == > $data = array('location' => 'location1'); > $form= $this->_getTestForm(); > $form->populate($data); > ... > > == > > all i did was change the array > > from > > $data = array('l

Re: [fw-general] Populating Zend_Form_Element_Select from database example

2009-01-31 Thread Daniel Latter
I still don't see where $this->data is set? in the form class for you to use it? what do you think gerardroche? Thank You Daniel Latter 2009/1/31 gerardroche : > > no. > > Change "in my controller" to the following > > in my controller > == > $data = array('location' => 'locati

Re: [fw-general] Populating Zend_Form_Element_Select from database example

2009-01-31 Thread gerardroche
no. Change "in my controller" to the following in my controller == $data = array('location' => 'location1'); $form= $this->_getTestForm(); $form->populate($data); ... == all i did was change the array from $data = array('location1' => 'location1'); t

Re: [fw-general] Populating Zend_Form_Element_Select from database example

2009-01-31 Thread Deepak Shrestha
On Sat, Jan 31, 2009 at 10:48 PM, Daniel Latter wrote: > Are you sure your setting $this->data variable in the form class?, and > if so var_dump it to see what it contains? > My sample trial code in my controller == $data = array('location1' => 'location1'); $form= $this->_ge

Fwd: [fw-general] Populating Zend_Form_Element_Select from database example

2009-01-31 Thread Daniel Latter
Thank You Daniel Latter -- Forwarded message -- From: Daniel Latter Date: 2009/1/31 Subject: Re: [fw-general] Populating Zend_Form_Element_Select from database example To: Deepak Shrestha Are you sure your setting $this->data variable in the form class?, and if so var_d

Re: [fw-general] Populating Zend_Form_Element_Select from database example

2009-01-31 Thread Deepak Shrestha
On Sat, Jan 31, 2009 at 10:37 PM, gerardroche wrote: > > you would just do this > > try this first: > > $data = array( >'location' => 'location1' > ); > $form->populate($data); > > > when the form is displayed it should show a select list of location options > with location1 selected. > > I t

Re: [fw-general] Populating Zend_Form_Element_Select from database example

2009-01-31 Thread gerardroche
you would just do this try this first: $data = array( 'location' => 'location1' ); $form->populate($data); when the form is displayed it should show a select list of location options with location1 selected. now try $data = array( 'location' => 'location2' ); $form->populate($dat

Re: [fw-general] Populating Zend_Form_Element_Select from database example

2009-01-31 Thread gerardroche
I'm not sure what it is that you want to know. Deepak Shrestha wrote: > >> It looks like your doing it correct except for the array of data that >> you're >> using to populate the form. You're not actually populating the select >> element with options, you only want the current Or selected opt

Re: [fw-general] Populating Zend_Form_Element_Select from database example

2009-01-31 Thread Deepak Shrestha
> It looks like your doing it correct except for the array of data that you're > using to populate the form. You're not actually populating the select > element with options, you only want the current Or selected option to be > selected in the select list on display. > > So in your case it's probab

Re: [fw-general] Populating Zend_Form_Element_Select from database example

2009-01-31 Thread gerardroche
It looks like your doing it correct except for the array of data that you're using to populate the form. You're not actually populating the select element with options, you only want the current Or selected option to be selected in the select list on display. So in your case it's probably a locat

Re: [fw-general] Populating Zend_Form_Element_Select from database example

2009-01-31 Thread gerardroche
Deepak Shrestha wrote: > > Hi, > > I am confused on how to populate the Select element from database. In > the Select element I need to fill it with location data which is > stored in database as single field table (each item is unique) > > location > -- > location1 > location2 >

[fw-general] Populating Zend_Form_Element_Select from database example

2009-01-31 Thread Deepak Shrestha
Hi, I am confused on how to populate the Select element from database. In the Select element I need to fill it with location data which is stored in database as single field table (each item is unique) location -- location1 location2 location3 ... ... etc. -- There is ver