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.

General Questions

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

Are Arrayed CMSFields Possible?


Reply

3 Posts   496 Views

Avatar
Tama

7 September 2011 at 3:02pm Community Member, 130 Posts

Howdy

I can't think of the right terminology to search the documentation/ interweb for a solution so I thought I'd ask here.

I want to extend the Page class so CMS users can upload and place images on a page (which gives us more control over where they place images compared to just inserting them into the HTML editor.)

Each image would need:
1. An upload field
2. A dropdown for placement (i.e. left, right, top, bottom)
3. A caption

However I want users to be able to do this for as many images as they want. I could create (for example) 6 groups of image fields but this would look cluttered on the CMS, and there's always the chance a user wants to add 8 images.

The ideal solution would be to have a tab that creates a new set of fields every time an image is added.

Is this possible?

Cheers
Tama

Avatar
Willr

7 September 2011 at 8:50pm Forum Moderator, 5511 Posts

Well you could represent those fields as a dataobject then attach a has_many relationship between your Page class and that new Dataobject.

Tutorial 5 covers the basics of dataobjects and relations: http://doc.silverstripe.org/sapphire/en/tutorials/5-dataobject-relationship-management

Avatar
Tama

8 September 2011 at 9:17am Community Member, 130 Posts

Thanks Will - that's what I'm after. Just couldn't think of the right search terms.