Verilen doktrin ile bir form oluşturduk.Symfony Form - "String veya Symfony Component Form FormTypeInterface", "dizi" türünde beklenen argüman
: Ben seçenekleri ile bir dizi eklerseniz o ( http://symfony.com/doc/current/book/forms.html#book-form-creating-form-classes) docs söylediği gibi,$builder ->add('name') ->add('password', 'password') ->add('password_repeat', 'password') ->add('email', 'email') ->add('save', 'submit') ;
Ama şeklinde bir hata alıyorum: Böyle, herhangi bir seçeneği geçemiyor eğer çalışır türü "dize veya Symfony \ Component \ Form \ FormTypeInterface" nin
Beklenen argüman, "dizi"
verilen bu doktrin tarafından oluşturulan formtype geçerli:
<?php
namespace MainBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class UserType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name') //if I put ->add('name', array('label' => 'Your name')) I get the error
->add('password', 'password')
->add('password_repeat', 'password')
->add('email', 'email')
->add('save', 'submit')
;
}
/**
* @param OptionsResolverInterface $resolver
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'MainBundle\Entity\User'
));
}
/**
* @return string
*/
public function getName()
{
return 'mainbundle_user';
}
}
teşekkür ederiz eklemeden önce! Symfony'de yeniyim, bu yüzden aptal bir soruydu, ama günümü kurtardın! –
Sadece sen sormazsan aptalca – Med