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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

GridFieldHasOneRelationHandler to Select Featured Gallery Image - Problem


Go to End


5 Posts   1618 Views

Avatar
timwjohn

Community Member, 98 Posts

16 July 2013 at 3:49am

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

Community Member, 98 Posts

16 July 2013 at 4:17am

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
(deleted)

Community Member, 473 Posts

16 July 2013 at 8:31am

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

Community Member, 98 Posts

16 July 2013 at 9:22pm

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

Community Member, 98 Posts

8 August 2013 at 9:06pm

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