22400 Posts in 6746 Topics by 2749 members
General questions about getting started with SilverStripe that don't fit in any of the categories above.
|Go to End|
3 December 2009 at 2:47am Last edited: 4 December 2009 12:36am
I am trying to get a simple new Module into the CMS (to edit several tables of data, maybe more in the future). I have been reading the example in the silverstripe book and I would like to create something very similar (with as little code as possible) to maintain the data in several reference tables. I'd like to be using ModelAdmin, but due to 2.2.2 I think using GenericDataAdmin is the best option.
At the moment I have a new DataObject called PromoCodes and a module called myadmin. The CMS display the new module in the top menu bar... but the left and right main sections are not close to my desire yet. Currently the left area shows a search form that when submitted shows the results, but not into the right area. And the right area shows the contents of the table (SELECT * FROM) but when a record is clicked it just refresehs the screen.
The left area I would like (if you have the book I am looking at 6.3 Using ModelAdmin for Data Management) to show this table/dataobject as part of a list or one of a set of tabs. Then selecting that table updates the right side with the 'search results' (select from table), then from this view a row could be viewed, editted or deleted. In the case of a view/edit I would like to have the right area become a single generic record editor. This is a wish, but anything that would accomplish maintaining this required data in the simplist code possible would be greatly appreciated.
I have included my current code and ask very politely if someone could please help me with this
class PromoCodes extends DataObject
static $db = array(
'ID' => 'Int',
'PromoCode' => 'Text',
'ExipryDate' => 'Date',
'IsLimted' => 'Boolean',
'Limit' => 'Int',
'Type' => "Enum(array('Percent', 'Fixed Value'))",
'DiscountAmount' => 'Int'
Object::addStaticVars('LeftAndMain', array('extra_menu_items' => array('Admin' => 'admin/myadmin/')));
Director::addRules(100, array('admin/myadmin/$Action/$ID' => 'MyAdmin'));
class MyAdmin extends GenericDataAdmin
public static $data_type = 'PromoCodes';
public static $result_columns = array('Promotional Code' => 'PromoCode',
'Exipry Date' => 'ExipryDate',
'Is Limted?' => 'IsLimted',
'Limit' => 'Limit',
'Type' => 'Type',
'Discount Amount' => 'DiscountAmount');
return new FieldSet(
new TextField('PromoCode', "PromoCode", "test"),
new CurrencyField('ExipryDate', "ExipryDate", "test")
<% if EditForm %>
<% else %>
<% end_if %>
<p id="statusMessage" style="visibility:hidden"></p>
<div id="treepanes" style="overflow-y: auto;">
4 December 2009 at 12:25am Last edited: 4 December 2009 12:28am
Sorry to hassle you nice folks, but I could really use some help here please.
I would upgrade if my predecessor had not customized the 'core' code so much.
Any help on how to add a module in 2.2.2 that will simply edit refernce data in DataObjects (that have already been created and all the site related functionality is there) would be very much appreciated - I've been on this for two days and it seems ridicuslous that it is so difficult.
8 December 2009 at 4:08am
There are a couple of options
* use the standard form functionality and build something custom (should take only a few hours).
* integrate modeladmin into your version (might be a nightmare, but worth a try)
* debug your current code into something that works
Between those three options I am sure there is hope ;-)
Best option: UPGRADE!
|Go to Top|