Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't include getGeneratedCMSFields when a subclass has no own fields or relations #31

Open
wernerkrauss opened this issue May 8, 2014 · 0 comments

Comments

@wernerkrauss
Copy link
Contributor

I stumbled across a problem with my Gallery implementation:

PageTypes:
  ImageGalleryPage:
    Fields: {}
    Components:
      ImageGalleryAlbum:
        Type: many
        Interface:
          Type: grid
        Tab: GalleryAlbum
  ProjektPage:
    Parent: ImageGalleryPage
    Fields: {}

Components: 
  ImageGalleryAlbum:
    Tab: GalleryAlbum
    Fields:
      Folder: {CMSField: RelationDropdown, Map: Folder}
      AlbumName: {CMSField: Textarea}
      Description: {CMSField: Textarea, DBField: Varchar(255)}
      CoverImage: {CMSField: Image}

When trying to add an Album to the ProjektPage it doesn't work. Commenting out the whole getGeneratedCMSFields() method in ProjektPage made it working. The error was like:

Uncaught LogicException: byID can't be called on an UnsavedRelationList

After some testing i changed the code in getGeneratedFormFields to:

        $parentClassName = get_parent_class($this);
        $parentClass = new $parentClassName;
        $fields = ($parentClass->hasMethod('getGeneratedCMSFields'))
            ? parent::getGeneratedCMSFields()
            : parent::getCMSFields();

which seems to work for now in the subclass.

Please have a look at it. Thanks ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant