Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » New page type: Specifying 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: 1899 Views
  • RonG
    Avatar
    Community Member
    11 Posts

    New page type: Specifying required fields Link to this post

    When creating a new page type, you can specify extra fields. Is it possible to specify if these fields are mandatory or optional to fill in (when a new page is created)?

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: New page type: Specifying required fields Link to this post

    Afaik validation in the cms doesn't work, so there's not a way to 'force' some fields to be filled out. This might be changed in the latest versions though, I'm not aware of that.

    You could add some literalfields to the getCMSFields() method though in which you specify/explain which fields are mandatory.

  • cerelac
    Avatar
    Community Member
    34 Posts

    Re: New page type: Specifying required fields Link to this post

    dio5, can you post an example of how to do it please?
    I've already tried to do something like this:

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

    ...
    new RequiredFields('Name', 'Age', 'City');

    ...
    return $fields;
    }


    I can't get this to work, if you could give an example I would appreciate.
    Thank you in advance.

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: New page type: Specifying required fields Link to this post

    Euhm, you can't. Like I said, there is no validation in the cms.

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