How to access the fields from the form data in symfony 3 -
i want use how access username , password fields below code.
appbundle\entity\masteruseraccount object ( [id:appbundle\entity\masteruseraccount:private] => [firstname:appbundle\entity\masteruseraccount:private] => [lastname:appbundle\entity\masteruseraccount:private] => [username:appbundle\entity\masteruseraccount:private] => test [password:appbundle\entity\masteruseraccount:private] => 123456 [createdby:appbundle\entity\masteruseraccount:private] => [updatedby:appbundle\entity\masteruseraccount:private] => [createdat:appbundle\entity\masteruseraccount:private] => [updatedat:appbundle\entity\masteruseraccount:private] => [status:appbundle\entity\masteruseraccount:private] => ) $data = $form->getdata(); $username = $data['username'];
i'm getting below error following error
cannot use object of type appbundle\entity\classname array
the data
out of symfony form entity
. can't access attribute of entity, arrays.
instead should using getter method defined inside class masteruseraccount
.
so. should be:
$username = $data -> getusername();
this assuming getter method defined inside masteruseraccount
class. if not, create getter method first.
Comments
Post a Comment