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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Are Arrayed CMSFields Possible?


Go to End


3 Posts   840 Views

Avatar
Tama

Community Member, 138 Posts

7 September 2011 at 3:02pm

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

Forum Moderator, 5523 Posts

7 September 2011 at 8:50pm

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

Community Member, 138 Posts

8 September 2011 at 9:17am

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