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.

Template Questions /

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

3 fields "Image" on the page

Go to End

2 Posts   1379 Views


Community Member, 39 Posts

11 December 2009 at 12:04pm

I need to set up 3 fields "Image" for my template.

I'm writing like this:

static $has_many = array(
"Image" => "Image",
"Image2" => "Image",
"Image3" => "Image"

public function getCMSFields()
$fields = parent::getCMSFields();

$fields->addFieldToTab("Root.Content.Main", new ImageField("Image"), "Content");
$fields->addFieldToTab("Root.Content.Bucket1", new ImageField("Image2"), "Content");
$fields->addFieldToTab("Root.Content.Bucket2", new ImageField("Image3"), "Content");

return $fields;

But the fields does not appear on the tabs "Bucket1" and "Bucket2".

Can you please help me with that?


Forum Moderator, 5523 Posts

11 December 2009 at 7:56pm

static $has_many = array( ..

A Page doesn't have 3 has_many images, Rather it should have them as a one to many rather then a many to many. So change that to

static $has_one = array(..

The image fields on the other BucketTabs are probably not showing due to the fact you are saying in your addFieldToTab to put them BEFORE a field called 'Content'. This 'Content' Field doesn't exist on the Bucket1, Bucket2 tabs so its not added. Try changing those lines to

$fields->addFieldToTab("Root.Content.Bucket1", new ImageField("Image2")); 
$fields->addFieldToTab("Root.Content.Bucket2", new ImageField("Image3"));