Re: DO Formbuilder: crosslinks (checkboxes) Problem solved !! ?
| From: | Alexander Petri | Date: | Mon, 06 Dec 2004 14:16:24 +0000 |
| Subject: | Re: DO Formbuilder: crosslinks (checkboxes) Problem solved !! ? | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-16050@lists.php.net to get a copy of this message | ||
so i finally updated the method &_generateForm(.....)
LINE (around) 956 to around 971:
foreach ($all_options as $key=>$value) {
/*$crossLinksElement =
HTML_QuickForm::createElement('checkbox', $groupName.'[]', null, $value);
$crossLinksElement->updateAttributes(array('value'
=> $key));
if (in_array($key, $selected_options)) {
$crossLinksElement->setChecked(true);
}*/
if(in_array($key, $selected_options)){
// echo "direct from DB ---- > ";
$crossLinkDefaults[$groupName][$key]=$key;
// echo $key."<br>\n";
}
// old one:
// $crossLinksElement =
$this->_createCheckbox($groupName.'['.$key.']', $value, $key, in_array($key,
$selected_options));
$crossLinksElement =
$this->_createCheckbox($groupName.'['.$key.']', $value, $key, false);
$element[] = $crossLinksElement;
}
and LINE 1185 (the last Lines in this method)
// Assign default values to the form
//print_r($crossLinkDefaults);
if(isset($crossLinkDefaults))
$formValues=array_merge($formValues,$crossLinkDefaults);
$form->setDefaults($formValues);
return $form;
this works great to me....
"Alexander Petri" <alex.petri@gmx.de> schrieb im Newsbeitrag
news:20041206134621.48238.qmail@pb1.pair.com...
> i pointed out another error:
> if you have a crosslink, the value "checked" is not setted by the method
> setDefaults
> there is an array $selected_options which is directly from the DB
> and is putted directly into the method _createCheckbox
> so it works like setConstants i guess...
>
> but Justin Patrin wrote:
> "Leaving a POST in the browser history can easily cause problems"
>
> i dont know really what this means, or if it is a problem for my thoughts
to
> solve
> the "crosslink Problem"
>
>
> "Alexander Petri" <alex.petri@gmx.de> schrieb im Newsbeitrag
> news:20041206123756.2383.qmail@pb1.pair.com...
> > The Problem was
> > if you do a submit on a form with crosslinks
> > and you want to show the form again (direct after it is submitted)
> > you will recognize that the "checked"-value on crosslinks are lost...
> > (i described the problem a short time ago in this mailing list)
> >
> >
> > Now i hope i solved this Problem:
> > in file DB/DataObject/FormBuilder.php Linie (around) 962
> > i changed this line:
> >
> > $crossLinksElement = $this->_createCheckbox($groupName.'[]', $value,
$key,
> > in_array($key, $selected_options));
> >
> > to this line:
> >
> > $crossLinksElement =
> > $this->_createCheckbox($groupName.'['.$key.']',
> $value,
> > $key, in_array($key, $selected_options));
> >
> > note this: '['.$key.']'
> >
> > now it seems to work...
> > it would be great to update the whole class if there are no side
> effects...
> >
> > another point are triple links LINE (around)1041
> >
> > $tripleLinksElement = $this->_createCheckbox('__tripleLink_' .
> > $tripleLink['table'] . '[' . $key1 . '][]',
> >
> > i guess there should be also:
> >
> > $tripleLinksElement = $this->_createCheckbox('__tripleLink_' .
> > $tripleLink['table'] . '[' . $key1 .
> > ']['.$key2.']',