3093 Posts in 875 Topics by 654 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1604 Views |
-
Modeladmin - not showing fields of managed dataobject

11 July 2009 at 5:15am
i was just trying to set up modeladmin on 2.3.2.
used exactly the code as in the docs (http://doc.silverstripe.org/doku.php?id=modeladmin).now, on the 'product' tab to the left, when i click search, in the search results only the fields 'Name' and 'Description' are shown, although the 'Product' class also defines 'Productcode' and 'Prize'. for some reason these fields don't get scaffolded.
see attached screenshot.i also tried managing a new dataobject with the following fields:
static $db = array(
'Headline' => 'Varchar',
'Teasertext' => 'Text',
'Fulltext' => 'Text'
);
when i view this in my modeladmin, none of the fields are shown, instead only the field 'ID' is used.are there some naming limitations on the db fields for objects managed by modeladmin?
btw. i got dataobjectmanager installed, don't know if this is somehow related.
anyone else having this problem?
-
Re: Modeladmin - not showing fields of managed dataobject

11 July 2009 at 8:23pm
ok, i got there.
seems i have to define '$summary_fields' on the managed object.
well, there's some interesting code in the dataobject class which explains why only the 'Name' and 'Description' fields were shown:if (!$fields) {
$fields = array();
// try to scaffold a couple of usual suspects
if ($this->hasField('Name')) $fields['Name'] = 'Name';
if ($this->hasDataBaseField('Title')) $fields['Title'] = 'Title';
if ($this->hasField('Description')) $fields['Description'] = 'Description';
if ($this->hasField('FirstName')) $fields['FirstName'] = 'First Name';
}
in my opinion, this is an ugly hack. summary_fields should fall back to all available fields instead. -
Re: Modeladmin - not showing fields of managed dataobject

14 July 2009 at 8:31am
> in my opinion, this is an ugly hack. summary_fields should fall back to all available fields instead.
Summary fields is not only used for a sequential display of fields, but also for table columns in the ModelAdmin result lists. Putting all available fields in there will make the table unuseable. Its a bit of hardcoding magic, but including stuff like "Title" by default seems helpful to avoid requiring specification of summary_fields for simple cases. For scaffolding your search, you should look at $searchable_fields.
-
Re: Modeladmin - not showing fields of managed dataobject

14 July 2009 at 7:39pm
well, but as mentioned in my initial post, i case you don't have any of those hardcoded fields on you dataobject, only the id is shown in the search result, which makes the table unuseable as well.
anyway, as there is the possibility to define summary_fields, it's really not much of an issue.
thanks for your post though
| 1604 Views | ||
|
Page:
1
|
Go to Top |


