If $bio->user_id is equal to zero, that means that there is no user in the bios table and the link can be shown. If there is already a bio in the table then the link should be hidden. This works like it’s supposed to but what I have in the controller is wrong. I wasn’t able to find much information by googling but I think that newEmptyEntity() creates a new table instead of accessing the table like I wanted to do. What should I use instead?
in the controller:
function admin($user_id = null) {
$bio = $this->Bios->newEmptyEntity();
$this->set(compact('bio'));
}
It’s the exact opposite of what it should be because if the field ‘created’ is set, then it shows the link and the link is hidden if the variable isn’t set. So it’s backwards but it only works if I do it this way. I can’t figure out why it’s working the opposite way it’s supposed to. So right now using it the way I’m showing, it hides the link because the bio exists.
$this->Bios->find('all') will find all the bios that exist in the database. And the thing that you set for the view is a query object, not an actual Bio entity, so who can say what calling ->created on that might give you. Did you mean something like: