1794 Posts in 590 Topics by 562 members
| Go to End | Next > | |
| Author | Topic: | 1714 Views |
-
SS3 ImageField / UploadField Problem

6 July 2012 at 2:15pm
Hi Guys, the new Silverstripe 3 image field looks great!
However I cant seem to get it working. I have been uploading images, then submitting my form, and when i print_r($data) from the form submission, all i seem to get out at the backend is the following:
"Pic" is the name
[Pic] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
=> 0
)Can anyone help out?
Cheers
Rob -
Re: SS3 ImageField / UploadField Problem

6 July 2012 at 2:20pm
BTW a look in the DB and assets folder shows that the images are actually being uploaded, however the problem is there is no link with my submitted form?
-
Re: SS3 ImageField / UploadField Problem

24 July 2012 at 4:54pm
I'm having the same problem. Did you manage to find a solution?
-
Re: SS3 ImageField / UploadField Problem

24 July 2012 at 5:11pm
Ah shit! I came here excited that you might have a solution for me!
I thought it might be because the actual Object that I was joining the image to might not have been written to the DB and assigned an ID, so I have tried editing one that had already been built on the front end, and this still didn't work.
I'm banging my head against a wall with this problem with no help, perhaps it needs to go in the "Upgrading to SS3" section?
I'd pay someone to show me where i'm going wrong.
-
Re: SS3 ImageField / UploadField Problem

24 July 2012 at 8:38pm
It would help if you show us some lines of your source code.
-
Re: SS3 ImageField / UploadField Problem

24 July 2012 at 9:31pm
Good point!
OK my Advert DO has this:
public static $has_one = array(
"Advertiser" => "Member",
"Category" => "Category",
"Pic" => "Image"
);My AddAdvert function Form() has the following code:
public function Form() {
$fields = singleton('Advert')->getFrontEndFields();
$fields->removeByName("Content");
$fields->removeByName("Moderated");
$fields->removeByName("AdvertiserID");
$fields->removeByName("Reported");
$fields->add(new AdvertContentField("Content", "Advert Text"));$categoryField = $fields->fieldByName("CategoryID");
$categoryField->setEmptyString("General / No Category");if (!Member::currentUser()) {
$fields->add(new RecaptchaField("recapture"));
}
$form = new Form(
$controller = $this,
$name = "Form",
$fields,
$actions = new FieldList(
// List the action buttons here
new FormAction("placeAd", "Place Your Advert")
),
$requiredFields = new RequiredFields(
"Content"
// List the required fields here: "Email", "FirstName"
)
);
$Params = $this->getURLParams();
$URLSegment = Convert::raw2sql($Params['ID']);if($URLSegment && $advert = Advert::get()->byId($URLSegment))
{
$form->loadDataFrom($advert);
}
return $form;
}And my placeAd() function has the following code:
public function placeAd($data, $form, $another) {
print_r($another);
print_r($data);
print_r($form);
die();
$form->saveInto($ad = new Advert());
//$ad->Content = $data["Content"];
$ad->write();
if ($curMember = Member::currentUser()){
$curMember->Adverts()->add($ad);
$ad->AdvertiserID = $curMember->ID;
}if ($data["CategoryID"]) {
$ad->CategoryID = $data["CategoryID"];
$category = Category::get()->byId($data["CategoryID"]);
$category->Adverts()->add($ad);
$category->write();}
$ad->write();
Session::set('info', 'Thanks for your submission');
return $this->redirectBack();
}obviously some debug statements in there, but i cant get any Pic information (IDs, Names anything) when the form is submitted.
-
Re: SS3 ImageField / UploadField Problem

29 July 2012 at 11:22pm
Biggest downside to Silverstripe is the total lack of activity on these forums!
I think the ImageField is broken on the frontend. I'm not going to post a ticket, as it could still be my code.
I got my form working by using "FileField" instead of "ImageField" then BOOM worked instantly.
If my PAIN IN THE ASS has helped you, please donate me some Bitcoins at this address:
15AhYGko4tVX2rXcg6A8GxeWoftfpUKvbM
Cheers Rob
-
Re: SS3 ImageField / UploadField Problem

29 July 2012 at 11:47pm
Hey Rob, I posted this ticket yesterday, see if it helps you. http://open.silverstripe.org/ticket/7715
| 1714 Views | ||
| Go to Top | Next > |



