Jump to:

23376 Posts in 18214 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » One DataObject, Two $has_ones...different fields?

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

Page: 1
Go to End
Author Topic: 151 Views
  • socks
    Avatar
    Community Member
    190 Posts

    One DataObject, Two $has_ones...different fields? Link to this post

    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

    151 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.