RE: [PEAR] DO and QF populating select options

From: Date: Sun, 16 Oct 2005 21:08:47 +0000
Subject: RE: [PEAR] DO and QF populating select options
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21507@lists.php.net to get a copy of this message
One other thing with FB.... The date fields default to 0 which throws and error in Windows. By using QF on its own, I was able to format the default date to today. How can I fix this in FB? Regards Prue -----Original Message----- From: Prue [mailto:prue@clipmagic.com.au] Sent: Monday, 17 October 2005 7:05 AM To: 'papercrane@reversefold.com' Subject: RE: [PEAR] DO and QF populating select options Thanks Justin, I've tried (and love FB) however I have a problem with that too which may be related to the issues I'm having here. I'm using Smarty templates and when I use FB, writing {$form.header.headertxt} or {$form.name.label}.in the templates, as it says to do in the manual (and I have read QF, DBDO, FB, Smarty manuals extensively and trawled the internet for tutorials as well as this mailing list) gives "Fatal error: Cannot use string offset as an array in..." In the example I'm trying without FB, I have: <snip> $person = DB_DataObject::factory(person ); $person ->selectAdd(); $person ->selectAdd('person_id'); $person ->selectAdd('name'); $person ->orderBy('name'); $person ->find(); while ($person -> fetch()) { /* store the results in an array */ $options[] = clone($person ); echo "got {$person->person_id},{$person->name}<br />"; /* this correctly outputs the required result to the screen */ } $form->addElement('select', 'person _id', 'Person', array($options['person _id']=>$options['person']) ); /* this results in an empty select box */ </snip> A dump of $options shows that the fields are two levels down in the array, eg $options[0][club_id] gives me the first row, which is as it should be however I don't know how to access that from within the QF element description. If I can fix this, ie get the key=>data as the first level in the array, I will happily go back to using the FB/Smarty combination. Any ideas? Regards Prue -----Original Message----- From: Justin Patrin [mailto:papercrane@gmail.com] Sent: Monday, 17 October 2005 3:11 AM To: prue@clipmagic.com.au Cc: pear-general@lists.php.net Subject: Re: [PEAR] DO and QF populating select options On 10/16/05, Prue <prue@clipmagic.com.au> wrote: > Hi > > This should be easy - everything I've read says so, but I cant get it > working. I have a DataObject that references another table via a > foreign key. The relationships are set up in links.ini. I can > factory the second table and retrieve the query, eg id and name which > will be the select options, but I cant work out how to then insert the > result into the QF select element options. > > Sorry this is such a dumb question. I've read, looked, tried > everything I can think of and I know it shouldn't be difficult but... > Look at the HTML_QF manual for how to add options to a select. Then loop over your DO records and add an option for each record. BTW, DB_DO_FB would do all this automatically for you. -- Justin Patrin -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.pear.general (#21507) next »