Jump to:

23377 Posts in 18296 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » ModelAdmin, CMSValidator & CTF Popup

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: 1093 Views
  • swaiba
    Avatar
    Forum Moderator
    1785 Posts

    ModelAdmin, CMSValidator & CTF Popup Link to this post

    I have a getCMSValidator returning my validator which works fine within the ModelAdmin EditForm, however once the form is opened into a CTF Popup - the validation isn't called.

    can anyone give me some pointers here please?

  • swaiba
    Avatar
    Forum Moderator
    1785 Posts

    Re: ModelAdmin, CMSValidator & CTF Popup Link to this post

    bump...

    Although I despise core code hack - I have tried adding the follwoing within __construct and forTemplate of ComplexTableField_Popup - but no luck...

       $validator = ($this->dataObject->hasMethod('getCMSValidator')) ? $this->dataObject->getCMSValidator() : new RequiredFields();
          $validator->setJavascriptValidationHandler('none');
          $this->setValidator($validator);

  • swaiba
    Avatar
    Forum Moderator
    1785 Posts

    Re: ModelAdmin, CMSValidator & CTF Popup Link to this post

    sorry to *bump* this again... but please can someone help me with this?

  • smares
    Avatar
    Community Member
    25 Posts

    Re: ModelAdmin, CMSValidator & CTF Popup Link to this post

    I had the problem until yesterday when I found out that the method called is getValidator and not getCMSValidator. :-/

  • swaiba
    Avatar
    Forum Moderator
    1785 Posts

    Re: ModelAdmin, CMSValidator & CTF Popup Link to this post

    smares - top man!
    That worked, now why didn't I try that one...

  • Andre
    Avatar
    Community Member
    126 Posts

    Re: ModelAdmin, CMSValidator & CTF Popup Link to this post

    Hi there,

    my Problem is a bid similar to the mentioned one here.

    I have inherited from ModelAdmin and modified it a bid, to be able to use a dataobjectmanager for the Listview instead of a ComplexTableField (to be able to sort the Managed Dataobjects).

    I needed some sort of Translation, where the Silverstripe Translation Decorator didn't work, so my Dataobjects are looking the following:

    DO App
    $db Title, Description
    $has_many AppTranslations

    DO AppTranslation
    $db Locale, Title, Description
    $has_one App

    The App Collection is managed through the ModelAdmin.
    I wrote a Validator for the AppTranslation, that checks, if the translation of a given locale was already set for the chosen App, to prevent from having more than one translation for each locale.

    But to make it more comfortable for the administrator, I would like to manipulate the Locales Dropdown of the AppTranslation Form, to show only the Translations left.

    For Example.
    I have allowed a Set of 4 Languages (de, en, es, fr).
    On App Item 1, there are Translations already set for de, en, so the Dropdown should only show es and fr for possible locale.

    I can do this inside getCMSFields Method of AppTranslation, but how do I get the reference to the Form Object inside this method, to receive the Parent ID (AppID)?

    regrads

    Andre

  • swaiba
    Avatar
    Forum Moderator
    1785 Posts

    Re: ModelAdmin, CMSValidator & CTF Popup Link to this post

    Sorry Andre - but I don't see how this is at all related to the above...

    1) you are using DOM for some of it
    2) the issue I had was asked and answerd - i.e. solved

    Please can you start a new thread where something *new* needs help on and if it is to do with DOM please post there

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