Has anyone got the ModelAdmin code working in RC4? If so, I would be grateful if you can share your code or share what I am doing wrong, thanks.
I've been having problems extending ModelAdmin in the RC4 and RC3 versions. It displays all right, but when I click the Create and Search buttons the ajax loading image fills the right hand screen and nothing happens (ajax error...)
I checked the Error console in Firefox and it gives me this error:
Too much recursion
$('Form_CreateForm').validate is not a function
I noticed that ModelAdmin loads both jquery and prototype, and the validation use $ function which they both use, so I'm thinking there must be a conflict? I'm not very good with javascript.
Great application by the way!
EDIT: If it helps, here is my other code:
Stockist Dataobject
<?php
/**
* Data representing a stockist
*/
class Stockist extends DataObject {
static $db = array(
'Name' => 'Varchar',
'Contact' => 'Varchar',
'Address' => 'Text',
'City' => 'Varchar',
'Postcode' => 'Varchar',
'Phone' => 'Varchar',
'Fax' => 'Varchar',
'Mobile' => 'Varchar',
'Email' => 'Varchar',
'Website' => 'Varchar',
'FullStockist' => 'Boolean',
'Date' => 'Date',
);
static $has_one = array(
'Location' => 'Location'
);
static $searchable_fields = array(
'Name' => array(
'field' => 'TextField',
'filter' => 'PartialMatchFilter',
),
'Contact' => array(
'field' => 'TextField',
'filter' => 'PartialMatchFilter',
),
'Address' => array(
'field' => 'TextareaField',
'filter' => 'PartialMatchFilter',
),
'City' => array(
'field' => 'TextField',
'filter' => 'PartialMatchFilter',
),
'Location.Name' => array(
'title' => 'Location',
'field' => 'TextField',
'filter' => 'PartialMatchFilter',
),
'Postcode' => array(
'field' => 'NumericField',
'filter' => 'ExactMatchFilter',
),
'FullStockist' => array(
'title' => 'Is a full stockist?',
'field' => 'CheckboxField',
'filter' => 'ExactMatchFilter',
),
'Location.InAustralia' => array(
'title' => 'Only in Australia?',
'field' => 'CheckboxField',
'filter' => 'ExactMatchFilter',
)
);
static $summary_fields = array(
'Name',
'City',
'Location.Name' => 'Location',
'Phone',
'FullStockist'
);
function getCMSFields() {
// test
$fields = new FieldSet();
$fields->push(new TextField('Name', 'Business Name'));
return $fields;
}
}
?>
StockistAdmin.php
<?php
/**
* Interface for maintaining stockists
*/
class StockistAdmin extends ModelAdmin {
protected static $managed_models = array(
'Stockist',
'Location'
);
static $url_segment = 'stockists';
static $menu_title = 'Stockists';
}
?>
Inside my config file
Director::addRules(50, array('admin/stockists/$Class/$Action/$ID' => 'StockistAdmin'));