field__fieldname delegation exclude fields.ini setting ?!

Archived from the Xataface Users forum.

doekia — Tue May 17, 2011 4:22 pm

Hello,

I discovered the hard way that if you implement a field_fieldname delegation function, aka a calculated field, multi-level properties ( those with : such as column:name ) are ignored / disabled.

This is probably due a collision between:

Code: Select all
Table::getField()       ...     if ( $delegate !== null and method_exists($delegate, "field__$fieldname")){    if ( isset($this->_atts[$fieldname]) ){      $schema = array_merge_recursive_unique($this->_newSchema('calculated',$fieldname), $this->_atts[$fieldname]);    } else {      $schema = $this->_newSchema('calculated', $fieldname);        }        return $schema;   }   ...

and

Code: Select all
Table::getProperty()   ...         $path = explode(':', $propertyName);    $arr =& $field;    while ( count($path)> 0 ){       $temp =& $arr[array_shift($path)];       unset($arr);       $arr =& $temp;       unset($temp);    }    return $arr;

property data from the fields.ini does not get splitted in the _atts array

Is there any elegant workaround this problem?

best,
(d)oekia


shannah — Wed May 18, 2011 12:52 pm

Can you elaborate on what you are trying to achieve? Perhaps there is a different way to achieve your goals.

-Steve


doekia — Sat Jun 04, 2011 9:17 am

Sorry I did not spotted your response earlier and I apparently badly expressed my-self

What I want to do is simply having a transient field obey the fields.ini settings.

I got this in my fields.ini

Code: Select all
`sql = select *,1 as icon_print_track_sheet from order_consolidated

[global]

[id_order]
  Key=PRI
  Extra=auto_increment
  widget:type = static
  visibility:list = visible
  column:label = “ID”
  order=0

[icon_print_track_sheet]
  visibility:list = visible
  column:label = “print”
  transient = 1
  not_findable = 1
  not_searchable = 1
  find = 0
  noLinkFromListView = 1
  order=50`

When the list is displayed, the header for the column icon_print_track_sheet does not follow the schema declaration.
I loose track from my initial post that was regarding the 1.3rc3 svn:2167, I have switched to svn version 2326.
So here follow the explaination based on svn:2326

The class Dataface_ResultList build the header within Dataface_ResultList::toHtml() (~ line 282) via
a call to Dataface_Table::getFieldProperty(‘column:label’,’icon_print_track_sheet’).
Dataface_Table::getFieldProperty(), split the property in path component and return the value from the property array returned by self::getField().
Dataface_Table::getField() does not return the same array depending on whether the field is normal/transient/grafted
if normal it return $this->_fields[$fieldname]
if grafted it returns self::graftedFields($fieldname)
if transient it returns self::transientFields($fieldname)

Both trasientFields and graftedFields return somehow the wrong array

Hope this helps
Unfortunatly the transient schema does not get splitted all along the path of the properties


shannah — Mon Jun 06, 2011 1:35 pm

Looks like a bug. However an easy workaround is to just use the widget:label directive on this column instead. This also affects the column heading.

-Steve


doekia — Mon Jun 06, 2011 1:41 pm

I am not quite sure widget:label will solve the issue (again it is a compound property e.i xxx:yyy).
I have used the not yet documented field__column_label() (works with any property) in the delegated_class

Best,
(d)oekia


shannah — Mon Jun 06, 2011 1:47 pm

What do you mean by compound property? What is the effect you are trying to achieve in the app interface? In the example you showed, the widget:label directive in the fields.ini file would appear as the column heading in the list view for your grafted field.


doekia — Mon Jun 06, 2011 2:45 pm

I call compound a property with a column in its name since this is treated internally as a nested value (array path, compound, … what ever name fits your willing)

I just try to use REGULAR fields.ini schema with transient = 1 and a field__xxxxxx function in the delegation class, and NONE of the property matching the compound pattern get processed, because the returned array from getFieldProperty contains [‘column:label’] and not [‘column’][‘label’], same problem for widget:label or any property with a column char (:)