Jump to content

description image issue


Frank Vèssia
 Share

Recommended Posts

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

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

@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.

  • Like 2
Link to comment
Share on other sites

@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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...