Re: FormBuilder and update with frozen fields
| From: | Justin Patrin | Date: | Wed, 12 Oct 2005 20:11:07 +0000 |
| Subject: | Re: FormBuilder and update with frozen fields | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-21410@lists.php.net to get a copy of this message | ||
On 10/12/05, Alessandro Pasotti <ale.pas@tiscali.it> wrote:
> Hello,
>
> I saw a similar post with frozen dates, but cannot solve my problem,
>
> It seems that frozen fields (excluded from userEditableFields) are rendered as
> HIDDEN values, these are hence passed to the form.
>
> Maybe I'm wrong, but basically my script does this:
>
> -------
> $do = SIGDB_DataObject::factory($table);
> $do->get($id);
> $fb = SIGFormBuilder::create($do);
> $form = $fb->getForm("./?module=$module");
> if($form->validate()) {
> $db->autoCommit(false);
> $result = $form->process(array(&$fb,'processForm'), false);
> if($result === true) {
> $db->commit();
> return 'ok';
> } else {
> // print some error stuff
> }
> }
> print $form->toHtml();
> -------
>
>
> What happens on update?
>
> $do->get($id) repopulate the form with old values, and formbuilder overwrite
> only userEditableFields, this is ok, but when processForm calls
> $this->_do->update() DO has all values set (old and new) together, the
> resulting query updates all fields, frozen or not.
>
> This is not the expected behaviour, I wish a query to update only fields that
> are not frozen.
>
> Am I doing something wrong?
>
This is normal behavior for DB_DO. FormBuilder does *not* set the
values of frozen (non-editable) fields to the DO. They are set when
you fetch. However, DB_DO always sends all fields in an UPDATE call if
a DO is not provided in the update() call.
However, FormBuilder *is* set up to only update what has been updated
by passing in the original DO to the update() call. Are you using the
newest version of FormBuilder? Are you setting the DO correctly on
submission? How do you know that the query contains everything? I
just tested this myself and only the updated fields are sent in my
queries.
--
Justin Patrin