We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Form entity bind problems

Hi, I have one again a new problem :P I am using a form to bind user-input-data (from POST) to the corresponding model-object. I am doing this without any problems on several places in my code. However, the example underneath will not save the profile data in my DB for any reason. I do not get an error and even the success message includes the correct POST-data ($profile->vorname, $profile->nachname), which shows, that the binding should be ok. But nothing will be stored in my DB.

$data = $this->request->getPost();

$profileForm = new ProfileForm()
$profileForm->bind($data,$profile);

if(!$profile->save()) {
    $this->flash->error($profile->getMessages());
} else {
    $this->flash->success("Profile (" . $profile->vorname." ".$profile->nachname . ")  saved.");
}

If I manually bind the data in the form, the saving works.

$profile->vorname = $data["vorname"];
$profile->nachname = $data["nachname"];

I am very confused because a) I already used the binding method without problems in my code b) I don't get an error message even though the model is not saved properly and c) because the data-binding itself seems to work.

Any ideas, known bugs or anything? Thank you :)

https://github.com/phalcon/cphalcon/blob/master/phalcon/forms/form.zep#L182

So:

  • you sure there is such element in form ?
  • you sure that model have public property or setter or it's not a relation alias ?