Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

One DataObject, Two $has_ones...different fields?


Reply


204 Views

Avatar
socks

Community Member, 190 Posts

1 November 2013 at 5:26pm

SS3.1

Back in the DOM days, I had this working, but haven't found a solution in SS3.

How can I hide some fields for MenuPage but show it on MenuPageFamilyMeals without creating two DataObjects?

class MenuItem extends DataObject {

private static $db = array(
    'MenuItemName' => 'HTMLVarchar(80)',
    'MenuItemDescription' => 'HTMLText',
    'FamilyMeal' => 'Enum("Family_Meal,Additional_Family_Meal")'
);

private static $has_one = array(
   'MenuPageFamilyMeals' => 'MenuPageFamilyMeals',
   'MenuPage' => 'MenuPage'
);

function getCMSFields() {
$fields = parent::getCMSFields();

...

return $fields;
}

}

Thanks