0
我想添加一個額外的步驟來註冊。我有我自己的FormType「Firma」,它試圖在registerController中獲得我的附加方法。當調用控制器這一行動得到一個錯誤:Symfony2 FOSUserBundle - 附加表格
<service id="my_user.firma.form.type" class="My\FrontendBundle\Form\Type\FirmaType">
<tag name="form.type" alias="my_user_firma" />
<argument>My\FrontendBundle\Entity\Firma</argument>
</service>
杉:在RegisterController
public function nextStepAction($token) {
$user = $this->container->get('fos_user.user_manager')->findUserByConfirmationToken($token);
if (null === $user) {
throw new NotFoundHttpException(sprintf('The user with confirmation token "%s" does not exist', $token));
}
$this->container->get('fos_user.user_manager')->updateUser($user);
$form = $this->container->get('my_user.firma.form.type');
.
.
.
return $this->container->get('templating')->renderResponse('FOSUserBundle:Registration:register.html.' . $this->getEngine(), array(
'form' => $form->createView(),
'theme' => $this->container->getParameter('fos_user.template.theme'),
));
service.xml的
Fatal error: Call to undefined method My\FrontendBundle\Form\Type\FirmaType::createView() in /var/www/Budowlanka/src/My/FrontendBundle/Controller/RegistrationController.php on line 107
nextStepAction行動MATYPE:
namespace My\FrontendBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
class FirmaType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('nazwa')
->add('ulica')
->add('nr_budynku')
->add('nr_lokalu')
->add('miasto')
->add('kod_pocztowy')
->add('poczta')
->add('telefon_1')
->add('telefon_2')
->add('email')
->add('www')
->add('liczba_opinii')
->add('nip')
->add('imie')
->add('nazwisko')
->add('haslo')
->add('logo')
->add('opis_uslug')
->add('data_dodania')
->add('data_modyfikacji')
->add('slug')
->add('specjalizacje')
;
}
public function getName()
{
return 'my_frontendbundle_firmatype';
}
}
編輯:
它的偉大工程,但現在我有從多對多關係字段標籤的問題。
->add('specjalizacja', 'entity', array(
'label' => 'Specjalizacje',
'multiple' => true,
'expanded' => true,
'property' => 'nazwa',
'class' => 'My\FrontendBundle\Entity\Specjalizacja',
'query_builder' => function(\Doctrine\ORM\EntityRepository $er) {
$qb = $er->createQueryBuilder('g');
return $qb->orderBy('g.nazwa', 'DESC');
}
)
它顯示 'my_user_firma_form_specjalizacja_110' 的標籤(110是記錄的ID),而不是實體的字段由...。我在Specjalizacja實體類中有一個__toString()方法
你在107線上的代碼是什麼? – 2013-04-05 14:23:29