21489 Posts in 5783 Topics by 2622 members
General Questions
SilverStripe Forums » General Questions » Model Admin - so many questions, so little documentation
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | Next > | |
| Author | Topic: | 6856 Views |
-
Model Admin - so many questions, so little documentation

10 March 2009 at 4:06pm Last edited: 10 March 2009 4:07pm
Hi all,
Okay, so I'm currently working with Model Admin for the first time and finding resources for it a little thin on the ground. I have some questions I'm hoping can be answered by the community:
1. Is there a way to dynamically change the allowed actions for the ModelAdmin on a per-class basis? I'm assuming it is done with $allowed_actions, however I've not been able to actually accomplish this after trying what seems like every conceivable option.
2. When Importing, is it possible to import data in relation to a FileIFrameField? Ie, upload the files first, then import the DO with a relationship to the file?
3. When using the "Select result columns..." function, if you select none and try to search, you get an error as follows:
Warning: "array_fill() [function.array-fill]: Number of elements must be positive" at line 624 of F:\sitename\cms\code\ModelAdmin.php
Given that there is a physical option to select none of the columns to show, there should be a nicer error message (or even a popup stopping the search before it happens).
4. Is there a way to sort the search results in the TableListField or to have it appear on opening the page?
That should do for now... ;) Anyone got any advice?
- DesignCity
-
Re: Model Admin - so many questions, so little documentation

19 March 2009 at 4:27pm
I'd like to put in a request for more information on how to automatically load an unconstrained search result when a ModelAdmin tab opens as well.
-
Re: Model Admin - so many questions, so little documentation

19 March 2009 at 4:32pm
And, while I'm not sure this fits here exactly, I have a little example to share about how to create a many_many relationship that has additional metadata in Silverstripe as well.
In the example, we have Teachers and Students. A teacher can have multiple students, and a student can have multiple teachers. This would normal just be a many_many relationship. However, in this case, we have additional data we would like to store about the relationship - a grade. This no longer fits the Silverstripe model, so you have to make your own relationship table.
-
Re: Model Admin - so many questions, so little documentation

23 March 2009 at 11:29pm
Bumping this thread...
1> Is there a way to automatically load a search result when the modeladmin is opened ?
2> How does sorting work in the ModelAdmin ?
-
Re: Model Admin - so many questions, so little documentation

13 May 2009 at 11:19pm Last edited: 14 May 2009 12:43am
Reviving...
a. Seems that in version 2.3.2 beta $managed_objects now needs to be public.
b. The bug where you can fysically select 'none' for searchfields is not repaired in 2.3.2. Suggestion: [EDITED] use 'ID' as a default? Or refuse to search?
c. When adding/editing a record in the secundary tab (category in the product/category example) the complete cms is reloaded, thereby reverting the tabset to its default state (product) where the right screen still shows the category. - This means you have to be very alert when you want to add/edit again, or you end up editing the wrong dataobject...
d. I regularly get some weird effect where after edit/save a search will now show a wrongly formatted page: sometimes it's just the right screen, sometimes the tablefield is replaced by flat text... (FF3.1 XP). I guess this is some javascript deficiency in my browser, but thougt to mention anyway...
-
Re: Model Admin - so many questions, so little documentation

4 June 2009 at 5:13pm
I too would like to know how to show a default result set, rather than needing to press 'search'.
-
Re: Model Admin - so many questions, so little documentation

4 June 2009 at 5:15pm
Bump: I'd love to see some answers to some of these questions, especially changing the way that things work/display by default.
-
Re: Model Admin - so many questions, so little documentation

5 June 2009 at 9:15am
> 1. Is there a way to dynamically change the allowed actions for the ModelAdmin on a per-class basis? I'm assuming it is done with $allowed_actions
No there isn't. Whats the use case?
> 2. When Importing, is it possible to import data in relation to a FileIFrameField? Ie, upload the files first, then import the DO with a relationship to the file?
I'd suggest you put the files into /assets, run Filesystem::sync() to ensure they're all File objects in your database. Then note the file paths in your CSV data, and cross match them in a custom method in a subclassed CSVBulkLoader. You can assign custom loaders in ModelAdmin::$model_importers.
> 3. When using the "Select result columns..." function, if you select none and try to search, you get an error as follows:
True, fixed in trunk (r78425)
> Is there a way to sort the search results in the TableListField or to have it appear on opening the page?
It uses DataObject::$default_sort. You can overload ModelAdmin->getResultsTable() and ModelAdmin->getCustomQuery() for any custom sorting.
> I'd like to put in a request for more information on how to automatically load an unconstrained search result when a ModelAdmin tab opens as well.
http://open.silverstripe.com/ticket/3693
Patches welcome
| 6856 Views | ||
| Go to Top | Next > |





