Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS

GridFieldHasOneRelationHandler to Select Featured Gallery Image - Problem


Reply

5 Posts   454 Views

Avatar
timwjohn

16 July 2013 at 3:49am Community Member, 98 Posts

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.

Avatar
timwjohn

16 July 2013 at 4:17am Community Member, 98 Posts

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?

Avatar
simon_w

16 July 2013 at 8:31am Forum Moderator, 474 Posts

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?

Avatar
timwjohn

16 July 2013 at 9:22pm Community Member, 98 Posts

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

Avatar
timwjohn

8 August 2013 at 9:06pm Community Member, 98 Posts

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