17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1360 Views |
-
Adding an image tab to a Contact Form

26 September 2008 at 3:57am
I've added an "Images" tab to most of my pages, so that I can add an image that is also displayed in the Holder page enclosing it. I've done this in the following way:
Opening the page's .php file
Adding
static $has_one = array(
'Photo' => 'Image'
);and
function getCMSFields($cms) {
$fields->addFieldToTab("Root.Content.Images", new ImageField('Photo'));
return $fields;
}as described in the tutorials. Works perfectly
However, I've tried to do the same in UserDefinedForm.php. It initially seems to work, but when I try to upload the image (or select one from the File Store) and click "attach image", it displays "ERROR. The website server has not been able to respond to your request."
Any help gratefully received.
Thanks
-
Re: Adding an image tab to a Contact Form

26 September 2008 at 9:58pm
First thing is to get a proper error message by setting the site into 'development' mode by adding
Director::set_environment_type("dev");
to your mysite/_config.php file. This will give you a more useful message!
-
Re: Adding an image tab to a Contact Form

27 September 2008 at 12:49am Last edited: 27 September 2008 12:51am
I think the way you've added the getCMSFields() function could be the problem.
The way we usually do it is like this:
function getCMSFields() {
$fields = parent::getCMSFields();$fields->addFieldToTab('Root.Content.Main', new TextField('MyField'));
return $fields;
}Where abouts did you get this code example from?
function getCMSFields($cms) {
$fields->addFieldToTab("Root.Content.Images", new ImageField('Photo'));
return $fields;
}This is a deprecated way of implementing getCMSFields().
Sean
-
Re: Adding an image tab to a Contact Form

27 September 2008 at 2:35am
Thanks guys.
I noticed that I didn't have the same problem with one of my other sites, and released that the problematic one was still using Silverstipe 2.2.1. I upgraded it, and now it works
| 1360 Views | ||
|
Page:
1
|
Go to Top |



