unclear understanding formBuilder getSelectOptions

From: Date: Thu, 03 Jun 2004 17:32:01 +0000
Subject: unclear understanding formBuilder getSelectOptions
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-12878@lists.php.net to get a copy of this message
Hi -- I'm having usage problems (ie, lack of understanding) of how to successfully use getSelectOptions in FormBuilder. Perhaps I misunderstand the function itself? I think it is to display text options when you have a dropdown menu composed of options from a linked table. I have a form with a link to another table, the link is being read by the morchand.links.ini file as such: [mc_User_Contact_Info] ; link value of type_id to table mc_User_Account_Types, match type_id column type_id = mc_User_Account_Types: type_id It works. And the dropdown menu in my form displays with the values (and selected values) set correctly. So all is good BUT -- I cannot figure out how to get the options to display the proper field. So my dropdown menu appears blank -- even though it has the correct values set for each option. I've tried a bunch of options to set this, but I'm honesty not sure what do or how to interpret the instruction. (I am going by the instruction I generated from phpdoc for formbuilder that is here: http://67.19.16.19/tests/fbdocs/DB_DataObject_FormBuilder/DB_DataObject_FormBuilder.html#methodgetSelectOptions) Would someone help fix my semantics / understanding here? I would appreciate it <relevant code> $do = DB_DataObject::factory('mc_User_Contact_Info'); $do-> get('contact_id', 1); // Debug text for my own purposes echo "<pre>"; print_r($do); echo "</pre>"; // NOTE -- the above prints correctly -- here is the relevant snippet from this output that demonstrates that the field type_id is linked to the table mc_user_account_types /* [_type_id] => dataobjects_mc_user_account_types Object ( [_DB_DataObject_version] => 1.6.0 [__table] => mc_User_Account_Types [N] => 4 [_database_dsn] => [_database_dsn_md5] => aabb2a967b2f1b3945ec804ab558c59e [_database] => morchand [_DB_resultid] => 1 [_link_loaded] => [_join] => [_lastError] => [type_id] => 1 [account_type] => Student [account_permissions] => [ type_id] => 2 [_query] => Array */ $fg =& DB_DataObject_FormBuilder::create($do); // more debug text for me -- this correctly prints "Student" echo "account type: " . $do->_type_id->account_type . "<br>"; $fg ->_form = true; $form =& $fg->getForm($_SERVER['PHP_SELF']); echo $form->toHtml(); </ relevant code> Options I have tried to set the select option within the above section are as follows: $fg->getSelectOptions("type_id", "account_type"); $fg->getSelectOptions("type_id", $do->_type_id->account_type); $fg->getSelectOptions("_type_id", $do->_type_id->account_type); $fg->getSelectOptions($do->_type_id, $do->_type_id->account_type); $fg->select_display_field = $do->_type_id->account_type; I tried setting this in the morchand.links.ini file but was just guessing at semantics and I'm not clear how to set the ini file so that "For the display name of the option, it will try to use the settings in the database.formBuilder.ini file" -- since my app has many tables and not just one set_display_field. Any usage example &/or clarification of my misunderstanding of this would be most appreciated. Thanks, s.

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