Frank Vèssia Posted February 18, 2013 Share Posted February 18, 2013 I'm freaking out with this piece of code, cannot find the problem here, I just want to edit the description of an image. if ($input->urlSegment1!=''){ $action = $input->urlSegment1; $action = explode("-",$action); $userID = (int)$action[1]; $m = $users->get($userID); if($m->id){ $m->of(false); if ($action[0]=='accept'){ $m->imageverify->first()->description = "verified"; $m->addRole("verified"); }elseif ($action[0]=='reject'){ $m->imageverify->first()->description = "rejected"; } $m->save(); $m->of(true); $session->redirect("/backend/",false); } } The description remains as it is, any change.... Link to comment Share on other sites More sharing options...
arjen Posted February 18, 2013 Share Posted February 18, 2013 Perhaps the imageverify Image field is set as a single file? I can image it won't work with ->first. Link to comment Share on other sites More sharing options...
Wanze Posted February 18, 2013 Share Posted February 18, 2013 Basic question: Are you sure the user is found? Debug mode on and no error messages? Link to comment Share on other sites More sharing options...
Frank Vèssia Posted February 18, 2013 Author Share Posted February 18, 2013 I've already debugged all...any error, all the variables are ok@arjen: according to what Ryan said: "When output formatting is OFF then your images field will always behave as an array. The single-image reference (with setting 1) is primarily for front-end syntactic convenience so that you can do echo $page->image->url rather than $page->image->first()->url. But behind the scenes, it's still always an array. " @wanze: I check the user with if($m->id) ... Link to comment Share on other sites More sharing options...
WillyC Posted February 18, 2013 Share Posted February 18, 2013 only.use post u shold for action.that changess.db for.this work it can.how it is.evenif not good mabe $m->trackChange('imageverify'); $m->save(); ? 1 Link to comment Share on other sites More sharing options...
Frank Vèssia Posted February 18, 2013 Author Share Posted February 18, 2013 @WillyC: I didn't understand anything but adding the trackChange now the code works. Thank you so much!! 1 Link to comment Share on other sites More sharing options...
nik Posted February 18, 2013 Share Posted February 18, 2013 @sevarf2: You hit the same bug I did a while back . See here: https://github.com/ryancramerdesign/ProcessWire/issues/147 So you can either: 1) use trackChange() like WillyC showed you or 2) force the save of (only) the imagefield with $m->save('imageverify') or 3) update to a more recent version of PW where this bug has been fixed (dev branch) and use plain old $m->save() like you were trying to in the first place. 2 Link to comment Share on other sites More sharing options...
Frank Vèssia Posted February 18, 2013 Author Share Posted February 18, 2013 Thanks Nik Link to comment Share on other sites More sharing options...
arjen Posted February 19, 2013 Share Posted February 19, 2013 @arjen: according to what Ryan said: "When output formatting is OFF then your images field will always behave as an array. The single-image reference (with setting 1) is primarily for front-end syntactic convenience so that you can do echo $page->image->url rather than $page->image->first()->url. But behind the scenes, it's still always an array. " Didn't know that. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now