Hi All,
I have building a site where I want to extend the Member object (FamilyMember.php) to include a few more fields. I then want to create a Family DataObject which will be a $has_many relationship with FamilyMember.
Now all seems to be working correctly except for the fact that in the ModelAdmin when I go to add a FamilyMember (there is a second tab automatically created for this) the EMAIL field is set as readonly so I cannot enter an email address. So when I submit it tells me that Email is a required field and won't let me submit...
I assume this might be something to do with the relationships but I have no real idea...
Any help would be appreciated. I am sure it is just something silly that I am not doing correctly.
Thanks in advance,
Colin
FamilyMember.php
<?php
//mysite/code/FamilyMember.php
class FamilyMember extends Member {
static $db = array(
'TwitterAccount' => 'Varchar(15)',
'FacebookProfile' => "Varchar(100)",
'RSSFeed' => "Varchar(100)",
'Website' => "Varchar(100)",
);
static $has_one = array(
'Family' => 'Family'
);
}
?>
Family.php
<?php
//mysite/code/Family.php
class Family extends DataObject {
static $db = array(
'AccountNickName' => 'Varchar(50)',
'MothersID' => 'Int',
'FathersID' => 'Int',
'WhereAreYouFrom' => 'Varchar(150)',
'HowManyChildren' => "enum('None, One on the way, 1 Child,2 Children,3 Children,4 Children,5 Children,6 Children,7 Children, 8 Children, More than 8 Children')",
'AgeOfYoungestChild' => 'Varchar(10)',
'AgeOfEldestChild' => 'Varchar(10)',
'TravelStatus' => "enum('Dreaming, Planning, On the Road, Finished')",
'TravelDuration' => "enum('less than 1 month, 1 month, 1-3 months, 3-6 months, 6-12 months, 1-2 years, indefinite')",
'DepartureDate' => 'Date',
'WhenWillYouFinish' => 'Date',
'TravelBudget' => "enum('Super Budget ( < than \$50/day), Budget (< than \$100/day), Medium (\$100 - \$200/day), Luxury ( > \$200/day)')",
'WhatDoYouWantToAchieve' => 'Text',
'FamilyInfo' => 'Text',
'NorthAmerica' => 'Boolean',
'CentralAmerica' => 'Boolean',
'Caribbean' => 'Boolean',
'SouthAmerica' => 'Boolean',
'MiddleEast' => 'Boolean',
'IndianSubcontinent' => 'Boolean',
'SouthEastAsia' => 'Boolean',
'NorthEastAsia' => 'Boolean',
'AustralasiaAndPacific' => 'Boolean',
'WesternEurope' => 'Boolean',
'EasternEurope' => 'Boolean',
'Africa' => 'Boolean',
'Enabled' => 'Boolean'
);
static $has_one = array(
'FamilyProfileImage' => 'Image'
);
static $has_many = array(
'FamilyMembers' => 'FamilyMember'
);
static $singular_name = 'Family';
static $plural_name = 'Families';
static $summary_fields = array(
'AccountNickName',
'WhereAreYouFrom',
'TravelStatus',
'TravelBudget'
);
static $searchable_fields = array(
'AccountNickName',
'WhereAreYouFrom',
'TravelStatus',
'TravelBudget'
);
}
?>
FamilyAdmin.php
<?php
class FamilyAdmin extends ModelAdmin {
static $managed_models = array(
'Family',
);
static $url_segment = 'families';
static $menu_title = 'Family Details';
}
?>