[FLOW3-general] Argument is NULL
René Zwinge
zwinge at psy-grafix.com
Sun Aug 29 20:51:14 CEST 2010
Hello guys,
i read the tutorial and i work on my own project. I create a user-management section and i want to delete user, here the code:
Index.html:
<f:for each="{users}" as="user">
<f:link.action onclick="return confirm('Really delete this post?');" action="delete" arguments="{user: user}" controller="User">Delete</f:link.action> - {user.firstname} {user.lastname} | {user.userid}<br />
</f:for>
There is a deleteAction with an argument and an user object. The foreach is correct and show me all users.
When i click "Delete", then it comes this error:
#1269616784: The value of argument "user" must be of type "F3\Spirit\Domain\Model\User", but was of type "NULL".
Here my UserController.php:
/**
* @inject
* @var \F3\Spirit\Domain\Repository\UserRepository
*/
protected $userRepository;
/**
* Index action
* The Index Action shows a list of all users
*
* @return void
*/
public function indexAction() {
if ($this->userRepository->findActive()===FALSE) {
$user = $this->objectManager->create('F3\Spirit\Domain\Model\User');
$user->setUserid(1);
$user->setFirstname('Rene');
$user->setLastname('Zwinge');
$this->userRepository->add($user);
}
$users = $this->userRepository->findAll();
$this->view->assign('users', $users);
}
/**
* Displays a form for creating a new user
*
* @param \F3\Spirit\Domain\Model\User $newUser A new user object
* @return string An HTML form for creating a new user
*/
public function newAction(\F3\Spirit\Domain\Model\User $newUser = NULL) {
$this->view->assign('newUser', $newUser);
}
/**
* Creates a new user
*
* @param \F3\Spirit\Domain\Model\User $newUser A fresh User object which has not yet been added to the repository
* @return void
*/
public function createAction(\F3\Spirit\Domain\Model\User $newUser) {
$newUser->setUserid($newUser->generateUserid());
$this->userRepository->add($newUser);
$this->forward('index');
}
/**
* Deletes a user
*
* @param \F3\Spirit\Domain\Model\User $user Delete this user object
* @return void
*/
public function deleteAction(\F3\Spirit\Domain\Model\User $user) {
$this->userRepository->remove($user);
$this->forward('index');
}
It seems to me, that it is a bug.
Regards
Rene
More information about the FLOW3-general
mailing list