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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

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

One object two Image


Go to End


5 Posts   858 Views

Avatar
Nikolay

Community Member, 5 Posts

7 April 2011 at 12:41am

Hello, i seriously surprised, but i can't made easily two images at one Object (Page)

Based on tutorial, i add one more image at relation.
static $has_one = array(
'PhotoLeft' => 'Image',
'PhotoRight' => 'Image',
);

It`s don't work, but i expect another.
I guess that the picture is not a "field ". This relation 1-1.
But strangely it is impossible to set two relation by different fields.

What's the easiest way to make two (not gallery) pictures in one page?

tnx, SS newbie :)

Avatar
Devlin

Community Member, 344 Posts

7 April 2011 at 12:55am

There is a getCMSFields() method in your Page class and you did rebuild the database with "/dev/build/?flush"?

Avatar
Nikolay

Community Member, 5 Posts

7 April 2011 at 12:58am

It`s like

$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Images", new ImageField('PhotoLeft'));
$fields->addFieldToTab("Root.Content.Images", new ImageField('PhotoRight'));

At Images folder i see only one upload form, and empty second field.

Avatar
Devlin

Community Member, 344 Posts

7 April 2011 at 1:29am

If you don't rebuild the database, the result would be a empty field. Turn on dev enviroment for proper error messages in your _config.php with ...

Director::set_environment_type("dev");

... and rebuild the database again.

Avatar
Nikolay

Community Member, 5 Posts

7 April 2011 at 2:23am

Rebuild the database make my happy :) bg tnx

I thing i do it many times before, and nothing happens.