Development

#4904 (Should sfForm have a blank saveEmbeddedForms() function?)

You must first sign up to be able to contribute.

Ticket #4904 (closed defect: fixed)

Opened 8 months ago

Last modified 8 months ago

Should sfForm have a blank saveEmbeddedForms() function?

Reported by: Jonathan.Wage Assigned to: fabien
Priority: minor Milestone: 1.2.0 RC1
Component: form Version:
Keywords: Cc:
Qualification: Unreviewed

Description

I am trying to do something like the following where I use a regular sfForm as a holder for all my Phonenumber forms for a UserForm?. This doesn't work because it expects that saveEmbeddedForms() exists. Should we add this method to sfForm or just alter sfFormDoctrine and sfFormPropel to only call saveEmbeddedForms() if the method exists?

class sfGuardUserAdminForm extends BasesfGuardUserAdminForm
{
  public function configure()
  {
    parent::configure();

    $profileForm = new ProfileForm($this->getObject()->getProfile());
    unset($profileForm['sf_guard_user_id']);
    $this->embedForm('Profile', $profileForm);

    $phonenumbersForm = new sfForm();
    foreach ($this->getObject()->getPhonenumbers() as $phonenumber)
    {
      $phonenumberForm = new PhonenumberForm($phonenumber);
      unset($phonenumberForm['sf_guard_user_id']);
      $phonenumbersForm->embedForm($phonenumber['id'], $phonenumberForm);
    }
    $this->embedForm('Phonenumbers', $phonenumbersForm);
  }
}

Change History

11/11/08 22:47:13 changed by Jonathan.Wage

Now that I think about this, I think this is invalid. Since saving is only related to the sfFormDoctrine and sfFormPropel. But, what I am trying to accomplish, is to have one entity named 'Phonenumbers' so that I can then enable that in the display array in the admin generator generator.yml.

generator:
  class: sfDoctrineGenerator
  param:
    model_class:           sfGuardUser
    theme:                 admin
    non_verbose_templates: true
    with_show:             false
    singular:              ~
    plural:                ~
    route_prefix:          sf_guard_user
    with_doctrine_route:     1

    config:
      fields:
        password_again: { label: "Password (again)" }

      list:
        title:   User list
        display: [=username, created_at, updated_at, last_login]

      form:
        class: sfGuardUserAdminForm
        display:
          "NONE":                   [username, password, password_again, Profile, Phonenumbers]
          "Permissions and groups": [is_active, is_super_admin, groups_list, permissions_list]

      edit:
        title: Editing User "%%username%%"
        actions:
          _delete:
          _new_phonenumber:
            action: newPhonenumber
            label: New Phonenumber
          _save:
          _save_and_add:
    
      new:
        title: New User

11/17/08 00:17:20 changed by fabien

  • status changed from new to closed.
  • resolution set to fixed.
  • milestone set to 1.2.0 RC1.

in r13043, and r13044

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.