| silent_mobius ( @ 2006-11-23 15:17:00 |
Y'see this is why I "Just don't get" Catalyst.
Ok so I have a list "method" for a table purchase_order right? The stuff that InstantCRUD spat out for Template::Toolkit actually makes sense this time (rather than the form handler that delegated everything to HTML::Widget which is _really_ starting to get on my nerves.) now there is a 1 to many relationship with the purchase_order_row table so InstantCRUD show an entry in the list view formed by:
[% FOR val = row.purchase_order_rows; val; ', '; END %] This lists all of the id's of the purchase_order_row rows that are associated with the current purchase_order row (still with me?) So I'd like that to simply be a count of those rows, after all I don't want the users to see the id's if I can help it.
So does TT have some way of doing scalar(@array) because that row.purchase_order_rows its a list right? No, its an object, its PurchaseOrder::Model::DBICSchemamodel::P which doesn't exist it seem to be constructed by PurchaseOrder::Model::DBICSchemamodel's parent Catalyst::Model::DBIC::Schema and looking at the source to that doen't really tell me much because it's so abstracted.
So how the hell do I get a count of row.purchase_order_rows in TT is there a method I can use to get at it? This is why Catalyst _needs_ some explicit docs. You can't spend an hour searching through inheritance just to work out what methods you can use, there should be a list, somewhere and it should never be unclear what a object _really_ is, maybe something like:
The default resultset passed to the default TT list controller (/MyApp/root/MyTableObject/list) created by the InstantCrud helper is a XXX that inherets from YYY and ZZZ. Supported methods are:
oooo (link) from YYY
pppp (link from ZZZ
...