Jump to:

5451 Posts in 1673 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » GridFieldHasOneRelationHandler to Select Featured Gallery Image - Problem

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

Page: 1
Go to End
Author Topic: 354 Views
  • timwjohn
    Avatar
    Community Member
    98 Posts

    GridFieldHasOneRelationHandler to Select Featured Gallery Image - Problem Link to this post

    Hi,

    I'm using GridFieldHasOneRelationHandler to select a featured Gallery Image. Here's my code:

          $featuredGalleryGridConfig = GridFieldConfig_RecordViewer::create();
          $featuredGalleryGridConfig->addComponent(new GridFieldHasOneRelationHandler($this, 'FeaturedGalleryImage'));
          $featuredGalleryGridField = new GridField('FeaturedGalleryImageID', 'Featured Gallery Image', GalleryImage::get(), $featuredGalleryGridConfig);
          $fields->addFieldToTab('Root.FeaturedGalleryImage', $featuredGalleryGridField);

    This seems to be causing a problem with pagination. I can change the selected image on the first page of the GridField, but if I try to navigate to the next GridField page, I get an error. The log says:

    Warning at \framework\forms\gridfield\GridState.php line 113: Cannot use a scalar value as an array (http://localhost/susangreenfield.com/admin/pages/edit/EditForm/field/FeaturedGalleryImageID)

    Oddly, if I change the GridField field from 'FeaturedGalleryImageID' to 'FeaturedGalleryImage', I can view the relationship, navigate the GridField pages, but changes won't save, though there is no error in the log.

  • timwjohn
    Avatar
    Community Member
    98 Posts

    Re: GridFieldHasOneRelationHandler to Select Featured Gallery Image - Problem Link to this post

    My Live site seems to be exhibiting different behaviour, even though all files are up-to-date and I did a dev/build?flush=1.

    This is what the log file is reporting:

    Unknown column 'Array' in 'field list' (http://susangreenfield.com/admin/pages/edit/EditForm)
    [15-Jul-2013 16:15:44] Warning at framework/model/fieldtypes/Int.php line 63: strpos() expects parameter 1 to be string, array given (http://susangreenfield.com/admin/pages/edit/EditForm)
    [15-Jul-2013 16:15:44] Error at framework/model/MySQLDatabase.php line 580: Couldn't run query:
    UPDATE "HomePage" SET "YouTubeVideoID" = '82t19rEI6U8', "ScribdLink" = null, "FeaturedGalleryImageID" = Array where "ID" = 6

    Unknown column 'Array' in 'field list' (http://susangreenfield.com/admin/pages/edit/EditForm)

    Any ideas?

  • simon_w
    Avatar
    Forum Moderator
    467 Posts

    Re: GridFieldHasOneRelationHandler to Select Featured Gallery Image - Problem Link to this post

    I released an update to the module yesterday. Can you update your version and see if that fixes it? If it doesn't, what version of SilverStripe are you running?

  • timwjohn
    Avatar
    Community Member
    98 Posts

    Re: GridFieldHasOneRelationHandler to Select Featured Gallery Image - Problem Link to this post

    Hi Simon,

    I checked out the version 1.0.3 yesterday, which didn't make a difference regarding my issue.

    I'm running version 3.0.5 of both CMS and Framework.

    Cheers,

    Tim

  • timwjohn
    Avatar
    Community Member
    98 Posts

    Re: GridFieldHasOneRelationHandler to Select Featured Gallery Image - Problem Link to this post

    Hi,

    Just wondered if there's any news on this. My client is having trouble saving certain pages on the site.

    The database is fairly old. In fact it was originally a 2.4 site. Could there be some remnants of data that are causing a conflict?

    In the meantime, I'm going to remove the field, but it makes choosing a Featured Gallery image a bit more difficult!

    Cheers,

    Tim

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