X-No-Archive:
======================
Symfony 1.2.7
Propel
======================

Hello,

    I want to use a profile with the sfGuard Plugin.
I embed sfGuardUserProfileForm into my own form :

<?php
class RegisterForm extends sfGuardUserForm {
public function configure()
{
 // Remove all widgets we don't want to show
unset($this['is_active'],
    $this['is_super_admin'],
...

// User Profile
 $profileForm = new sfGuardUserProfileForm();
$this->embedForm('Profile', $profileForm);

unset($profileForm['id'],
    $profileForm['user_id']
    );


The template _form.php look like :


    <tr>
        <th><?php echo $form['Profile']['last_name']->renderLabel() ?> </th>
        <td><?php echo $form['Profile']['last_name'] ?></td>
      </tr>
    <tr>
        <th><?php echo $form['Profile']['first_name']->renderLabel() ?></th>
        <td><?php echo $form['Profile']['first_name'] ?></td>
      </tr>
      <tr>
        <th><?php echo $form['username']->renderLabel() ?> :</th>
        <td><?php echo $form['username'] ?></td>
      </tr>
      <tr>
        <th><?php echo $form['password']->renderLabel() ?></th>
        <td><?php echo $form['password'] ?></td>
      </tr>
      <tr>
        <th><?php echo $form['password_confirmation']->renderLabel() ?></th>
        <td><?php echo $form['password_confirmation'] ?></td>

and the actions.class.php file :

<?php

class compteActions extends sfActions {

    public function executeNew(sfWebRequest $request)
    {
        $this->form = new RegisterForm();
    }

    public function executeCreate(sfWebRequest $request)
    {
        $this->forward404Unless($request->isMethod('post'));

        $this->form = new RegisterForm();

        $this->processForm($request, $this->form);

        $this->setTemplate('new');
    }

    protected function processForm(sfWebRequest $request, sfForm $form)
    {
        $this->form->bind($request->getParameter('sf_guard_user'));

        if ($form->isValid()) {
            $this->redirect('compte/liste');
        }
    }
}

But no database insert. The "user_id" field is required.
"user_id" is define in schema.yml as :

  sf_guard_user_profile:
    _attributes: { phpName: sfGuardUserProfile }
    id:
    user_id:     { type: integer, foreignTable: sf_guard_user,
foreignReference: id, required: true, onDelete: cascade }
    first_name:  varchar(20)
    last_name:   varchar(20)


How do I make the link between "user" en "profile" ?
And after that how can I make the distinction beetween "create" en "edit" ?

Thanks for your Help

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to