Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » About CMSFields, Default Values and Required Fields...

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1914 Views
  • dio5
    Avatar
    Community Member
    501 Posts

    About CMSFields, Default Values and Required Fields... Link to this post

    1) I was trying to set a default value for an OptionSetField in the cms, but just can't get it to work. Part of the code I used was http://pastie.caboo.se/124284.. tried a couple of other things too but just didn't get it to work. Note that I'm also using the populateDefaults method, so maybe that is interfering/overwriting?

    2) How can I set some fields as required? Can I do a new RequiredFields somewhere? Is there any method for it?

    thnx

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: About CMSFields, Default Values and Required Fields... Link to this post

    ok..

    When doing

    $countries = DataObject::get("Country");
    $this->CountryID = $countries->First()->ID;

    in the populateDefaults method it seems to work. Apparently setting a default value in the getcmsfields-method doesn't mix with it.

    Still interested in knowing how to make fields required in the backend though.

    1914 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.