Я пытаюсь переопределить форму редактирования FOSUserBundle для профиля, поэтому я так понимаю:
config.yml
fos_user: db_driver: orm firewall_name: main user_class: crmBundle\Entity\User profile: form: type: crmBundle\Form\ProfileFormType
services.yml
services: app.form.profile: class: crmBundle\Form\ProfileFormType tags: - { name: form.type, alias: crm_user_profile }
ProfileFormType.php
namespace crmBundle\Form; use FOS\UserBundle\Util\LegacyFormHelper; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Security\Core\Validator\Constraints\UserPassword; class ProfileFormType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $this->buildUserForm($builder, $options); $builder->add('current_password', LegacyFormHelper::getType('Symfony\Component\Form\Extension\Core\Type\PasswordType'), array( 'label' => 'form.current_password', 'translation_domain' => 'FOSUserBundle', 'class' => 'form-control', /// ???????????????? 'mapped' => false, 'constraints' => new UserPassword(), )); } // BC for SF < 3.0 public function getName() { return $this->getBlockPrefix(); } public function getBlockPrefix() { return 'crm_user_profile'; } protected function buildUserForm(FormBuilderInterface $builder, array $options) { $builder ->add('firstname', null, array('label' => 'form.firstname', 'translation_domain' => 'FOSUserBundle')) ; } }
Но я получаю ошибку: опция «класс» не существует.
Вот трассировка стека: http://pastebin.com/CE7dzi8s
Где проблема?
EDIT: Я исправил проблему с классом, но теперь я получаю ошибку:
Cannot read index "firstname" from object of type "crmBundle\Entity\User" because it doesn't implement \ArrayAccess.
Вот мой объект / пользователь
// src/crmBundle/Entity/User.php namespace crmBundle\Entity; use FOS\UserBundle\Model\User as BaseUser; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @ORM\Table(name="fos_user") */ class User extends BaseUser { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @var string * * @ORM\Column(type="string", length=255) */ private $firstname; public function getFirstname() { return $this->firstname; } public function setFirstname( $firstname ) { $this->firstname = $firstname; return $this; } /** * @var string * * @ORM\Column(type="string", length=255) */ private $surname; public function getSurname() { return $this->surname; } public function setSurname( $surname ) { $this->surname = $surname; return $this; } /** * @var string * * @ORM\Column(type="string", length=255) */ private $phone; public function getPhone() { return $this->phone; } public function setPhone( $phone ) { $this->phone = $phone; return $this; } /** * @var string * * @ORM\Column(type="string", length=255) */ private $city; public function getCity() { return $this->city; } public function setCity( $city ) { $this->city = $city; return $this; } /** * @var string * * @ORM\Column(type="string", length=255) */ private $ranks; public function getRanks() { return $this->ranks; } public function setRanks( $ranks ) { $this->ranks = $ranks; return $this; } public function __construct() { parent::__construct(); // your own logic } }