22432 Posts in 6925 Topics by 2751 members
General questions about getting started with SilverStripe that don't fit in any of the categories above.
|Go to End||Next >|
10 March 2009 at 4:06pm Last edited: 10 March 2009 4:07pm
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?
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.
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.
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 ?
13 May 2009 at 11:19pm Last edited: 14 May 2009 12:43am
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...
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'.
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.
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.
|Go to Top||Next >|