Home » Database » DB_DataObject_FormBuilder » Bug #4678
Setting field labels in preGenerateForm() fails
Details
| Submitted | 2005-06-25 10:30 UTC |
|---|---|
| From | sdteffen at gmail dot com |
| Assigned | justinpatrin |
| Status | Bogus |
| Package | DB_DataObject_FormBuilder |
| PHP Version | 4.4.0 |
| OS | Windows XP |
| Roadmaps | (Not assigned) |
Comments
[2005-06-25 10:30 UTC] sdteffen at gmail dot com
Description:
------------
Setting the field labels in preGenerateForm() is not
working any more with DB_DataObject_FormBuilder 0.17.2 (see
Actual result).
In version 0.15.0 things worked fine (See Expected result).
Please ignore the gettext calls (_()) in the code
below. They are working fine.
Note that setting of field labels in the DataObject class
also seems to fail.
Reproduce code:
---------------
/**
* Localize labels and buttons.
* @return Nothing.
*/
function preGenerateForm() {
$this->fb_fieldLabels = array('gid' => _('ID:'), 'subtype' => _('Type:'),
'village' => _('Village:'), 'administra' => _('Administrative Area:'),
'name' => _('Name:'), 'the_geom' => _('Location:'), 'x' => _('X:'),
'y' => _('Y:'));
$this->fb_submitText = _('Submit');
}
Expected result:
----------------
Field labels like 'ID:' and 'Type:'
Actual result:
--------------
The labels defined in preGenerateForm() are not used.
Instead the raw field names are used (e.g. 'id' or 'subtype')
[2005-06-29 22:38 UTC] lists at jystewart dot net
I am experiencing this problem too, but only in PHP4
(production environment is 4.3.10 which I can't change,
sadly).
No problem in PHP5 on my development box.
[2005-06-30 05:16 UTC] sdteffen at gmail dot com
I double-checked that DB_DATAOBJECT_NO_OVERLOAD is defined.
[2005-07-16 07:21 UTC] sdteffen at gmail dot com
In the meantime I also upgraded to PHP 4.4.0.
The problem for my application is still as
described below.
In your application things work fine, I could reproduce this.
The problem is that preGenerateForm() is not called
any more in my application once I switch from DB_DataObject 0.15.0 to 0.17.2. Any idea why this could happen?
[2005-07-18 05:16 UTC] sdteffen at gmail dot com
With 0.15.0,
var_dump($fb->preGenerateFormCallback) returns NULL,
with 0.17.2, it returns
array(2) {
[0]=>
&object(dataobject_landmark)(27) {
..snip..
}
[1]=>
string(15) "preGenerateForm"
}
This looks correct to me.
I'm using the standard FormBuilder class:
$objLandmarkBuilder = DB_DataObject_FormBuilder::create($objLandmark,
array());
I have to correct myself, preGenerateForm() is called now.
However,
DB_DataObject_FormBuilder::fieldLabels is array(0).
If I change the following function:
DB_DataObject_FormBuilder::getFieldLabel()
like below, things are working again:
function getFieldLabel($fieldName)
{
if (isset($this->_do->fb_fieldLabels[$fieldName])) {
return $this->_do->fb_fieldLabels[$fieldName];
}
return ucfirst($fieldName);
}
However, I'm not sure whether this is the right way.
I was unable to locate the place where DO->fb_fieldLabels
are taken over to FormBuilder.
[2005-07-18 06:16 UTC] sdteffen at gmail dot com
That's what I thought.
In populateOptions() the fieldLabels array is ok.
In getFieldLabels() not. What is in between?