Re: bug line 2838 formbuilder.php
| From: | Marco Sottana | Date: | Fri, 02 Mar 2007 10:09:44 +0000 |
| Subject: | Re: bug line 2838 formbuilder.php | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-26703@lists.php.net to get a copy of this message | ||
[code]
//file new.php
function nuovoX($head,$pk_name=null,$pk_value=null){
/*
$builder->forceQueryType(DB_DATAOBJECT_FORMBUILDER_QUERY_FORCEINSERT);
*/
$first_table =& DB_DataObject::factory($head);
$first_table->fb_createSubmit =!tableExists($head."_lang");
if(!is_array($pk_name)) $pk_name=explode(",",$pk_name);
if(!is_array($pk_value)) $pk_value=explode(",",$pk_value);
for($i=0;$i<count($pk_name);$i++){
echo "<br>".$pk_name[$i]."=".$pk_value[$i];
$first_table->$pk_name[$i]=$pk_value[$i];
}
$first_build =& DB_DataObject_FormBuilder::create($first_table);
$first_build->forceQueryType(DB_DATAOBJECT_FORMBUILDER_QUERY_FORCEINSERT);
//$first_build->elementNamePrefix = 'formOne';
$first_form = $first_build->getForm($_SERVER["REQUEST_URI"]);
//////////////////////////////////////////////////////////////////////////// if(!tableExists($head."_lang")){ if ($first_form->validate()) { $first_form->process(array(&$first_build,'processForm'), false); //$first_form->freeze(); echo "<h2>salvato correttamente</h2>"; } print $first_form->toHTML(); return ""; } $second_table = DB_DataObject::factory($head.'_lang'); $ext="id_".$head; /* $second_table->id_tbl_menu_sx=$id; $second_table->id_tbl_lingua=$_SESSION["editlang"]; */ /* $second_table->find(); $second_table->fetch(); */ $second_build =& DB_DataObject_FormBuilder::create($second_table); //$second_build->forceQueryType(DB_DATAOBJECT_FORMBUILDER_QUERY_FORCEINSERT); //$second_build->elementNamePrefix = 'formTwo'; $second_build->useForm($first_form,false); $second_form = $second_build->getForm($_SERVER["REQUEST_URI"]); if ($first_form->validate()){ if($first_form->process(array(&$first_build,'processForm'), false)){ /* echo "<br><h5>".$head."</h5>"; echo "<br>id ".$head." =>".$first_table->id; */ $second_table->$ext = $first_table->id; $second_table->id_tbl_lingua = $_SESSION["editlang"]; /*$do = $second_table->insert(); // perche' e' nuovo e ha 2 chiavi ?? if (PEAR::isError($do)) { // controllo errore die($do->getMessage()); }*/ }else{ echo "errore nel salvataggio ".$head; } }else{ //echo "<h1>!!first_form->validate</h1>"; } if($second_form->validate()) { //$second_table->$ext = $first_table->id; //$second_table->id_tbl_lingua = $_SESSION["editlang"]; if($second_form->process(array(&$second_build,'processForm'), false)){ if(is_object($second_table->$ext)){ $second_table->$ext = $first_table->id; $second_table->id_tbl_lingua = $_SESSION["editlang"]; } $do = $second_table->insert(); // perche' e' nuovo e ha 2 chiavi ?? if (PEAR::isError($do)) { // controllo errore die($do->getMessage()); } /* echo "<br><h5>".$head."_lang</h5>"; echo "<br>id_".$head." =>".$second_table->$ext; echo "<br>id_tbl_lingua =>".$second_table->id_tbl_lingua; */ }else{ //echo "errore nel salvataggio ".$head."_lang"; } //$first_form->freeze(); //$second_form->freeze(); echo "<h2>salvato correttamente</h2>"; }else{ //echo "<h1>!!second_form->validate</h1>"; } //print $second_form->toHTML(); //return $mdb2->lastInsertId(); $tpl = new Smarty(); //$tpl->compile_check = true; //$tpl->debugging = true; // initialize $tpl->template_dir = absdir.'/admin/templates/'; // (templates_c needs to be server-writeable) $tpl->compile_dir = absdir.'/admin/templates_c/'; $renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl,true); $renderer->setRequiredTemplate( '{if $error} <font color="red">{$label|upper}</font> {else} {$label} {if $required} <font color="red" size="1">*</font> {/if} {/if}' ); $renderer->setErrorTemplate( '{if $error} <font color="orange" size="1">{$error}</font><br /> {/if}{$html}' ); $second_form->accept($renderer); $tpl->assign('form', $renderer->toArray()); ///////////// per mettere le bandiere ///////////// $_SESSION["head"]=$head; $_SESSION["pk_name"]=$pk_name; $_SESSION["pk_value"]=$pk_value; //$_SESSION["hide"]=$hide; $extra=tool_bandiere($head,$pk_name,$pk_value); echo $extra; //////////////////////////////////////////////////// if (file_exists(absdir.'/admin/templates/'.$head.'.tpl')){ $tpl->display($head.'.tpl'); }else{ $tpl->display('automatic.tpl'); } //*/}[/code]mydb.ini[code][tbl_menu_sx]id = 129pub = 17nome1 = 2id_padre = 1checkbox_intention = 2posizione = 1checkbox_tbl_gruppi = 2checkbox_tbl_service = 2img = 2extra_link = 2tipo_menu = 2[tbl_menu_sx__keys]id = N[tbl_menu_sx_lang]id_tbl_lingua = 129id_tbl_menu_sx = 129nome = 130img = 2img1 = 2link = 2[tbl_menu_sx_lang__keys]id_tbl_lingua = Kid_tbl_menu_sx = K[/code]//file mydb.links.ini[code][tbl_menu_sx]id_padre = tbl_menu_sx:id[tbl_menu_sx_lang]id_tbl_menu_sx = tbl_menu_sx:idid_tbl_lingua=tbl_lingua:id[/code]the error apper whennuovoX("tbl_menu_sx","id_padre","1");----- Original Message -----From: "Justin Patrin" <papercrane@gmail.com>To: "Marco Sottana" <marco.sottana@q-web.it>Cc: <pear-general@lists.php.net>Sent: Thursday, March 01, 2007 7:04 PMSubject: Re: [PEAR] bug line 2838 formbuilder.php> On 3/1/07, Marco Sottana <marco.sottana@q-web.it> wrote:>> 8, Object to string conversion,....../PEAR/DB/DataObject/FormBuilder.php, 2838, Array>> Please fill out a full bug report including how you caused this to happen.>> --> Justin Patrin>> --> PEAR General Mailing List (http://pear.php.net/)> To unsubscribe, visit: http://www.php.net/unsub.php>>>