Reputation: 31
I am experiencing the following form error in Symfony:
Neither the property "email" nor one of the methods "email()", "getemail()"/"isemail()"/"hasemail()" or "__call()" exist and have public access in class "Symfony\Component\Form\FormView".
This is what my form looks like:
My App\Form\LostPasswordType:
namespace App\Form;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use App\Entity\LostPassword;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\AbstractType;
class LostPasswordType extends AbstractType
{
public function builder(FormBuilderInterface $builder, array $options)
{
$builder
->setAction('/forgotpw')
->setMethod('POST')
->add('mail', EmailType::class, [
'required' => true,
'label' => false,
'attr' => [
'autofocus' => false,
'class' => 'span8',
'placeholder' => '[email protected]'
]
])
->add('submit', SubmitType::class, [
'label' => 'Reset Password',
'attr' => ['class' => 'btn btn-primary btn-green']
])
;
}
public function configureOption(OptionsResolver $resolver)
{
$resolver->setDefaults(['data_class' => LostPassword::class]);
}
}
And this is my controller code:
$formReset = $this->createForm(
LostPasswordType::class,
$forgotpass,
array('csrf_protection' => false)
);
$formReset->handleRequest($request);
Does anyone know why I am receiving this error?
Upvotes: 0
Views: 649
Reputation: 31
I fixed the problem by changing the method function name in form builder, it was mistake there.
Upvotes: 1