私の質問-フィールドスラッグセットでユーザーを作成する場合-名+姓. フィールド firstname と lastname slug を更新しても変更されないのはなぜですか?また、この trable チェックのために何をする必要がありますか? ルーティングでスラッグ フィールド (ユーザー名) を使用するため、次のようにします。
class SUser implements UserInterface
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @Gedmo\Slug(fields={"firstName", "lastName"}, separator="-")
* @ORM\Column(name="name", type="string", length=255, nullable=false)
* @Assert\Length(min=3, max=255)
*/
protected $username;
私のフォーム:
class DeveloperPersonalInformationType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('firstname', null, array('label' => 'First Name', 'max_length' => 255, 'required' => false))
->add('lastname', null, array('label' => 'Last Name', 'max_length' => 255, 'required' => false))
カスタム バリアントを使用するようになりました。最初にユーザー名に姓と名の末尾を設定しますが、@Gedmo\Slug を使用したいのですが、どうすればよいですか? 私の行動:
public function submitPersonalInformationAction($username)
{
$em = $this->getDoctrine()->getManager();
$request = $this->get('request');
$profileRepository = $this->get('artel.profile.developer.repository');
$developer = $profileRepository->findOneByUsername($username);
$form = $this->createForm(new DeveloperPersonalInformationType(), $developer);
$form->handleRequest($request);
if ($form->isValid())
{
$name = $developer->getFirstName().'-'.$developer->getLastName();
$developer->setUsername($name);
$em->flush();
return $this->redirect($this->generateUrl('artel_profile_homepage', array('username' => $name)) .'#personal-information');
}
そして私の回転:
artel_profile_submit_personal_information:
path: /profile/{username}/personal_information/submit
defaults: { _controller: ArtelProfileBundle:DeveloperProfile:submitPersonalInformation }
requirements: { _method: post }
私の設定:
stof_doctrine_extensions:
default_locale: "%locale%"
orm:
default:
timestampable: true
sluggable: true