phpformssymfony-1.4propel

how to save a collection form in symfony 1.4


I have created a collection form in symfony 1.4 and Propel 1.5 and everything displays properly but I cannot get the form to save to the database.

The form is used to edit multiple users at once.

I found this question and I implemented the suggestion of extending my collectionForm class with sfFormPropel, but when I do that I run out of memory. I cannot find what is being pulled from the database that would fill up the processes memory.

In my new save function I am not even doing anything.

Any ideas?

class ContactCollectionForm extends sfFormPropel
{
    public function getModelName()
    {
        return 'ContactCollectionForm';
    }

    public function retrieveSubObject($fieldname, $model)
    {
        switch($fieldname)
        {
            default:
                break;
        }
        return array();     
    }

    public function save($con = null)
    {

    }

    public function configure()
    {
        $user           = $this->getOption('user');
        $embedded       = $this->getOption('embedded');
        $custom         = $this->getOption('custom');
        $contact_list   = $this->getOption('contact_list');
        $cf             = $custom['form'];

        if(!array_key_exists(0, $cf['fields']['field']))
            $cf['fields']['field']  = array($cf['fields']['field']);

        $use_fields     = array();

        for($i=0;$i<count($contact_list);$i++)
        {
            foreach($cf['fields']['field'] as $field)
            {
                if($field['type'] == 'object')
                {
                    // embed object form (ala: PersonData, Coordinate etc...)
                    $model      = $field['model'];
                    $model_form = $model.'Form';

                    $sub_object = $contact_list[$i];

                    $sub_form   = new $model_form($sub_object, array('user' => $user, 'embedded' => true, 'custom' => $field['fields']));
                    $this->embedForm($field['name'], $sub_form);
                    array_push($use_fields, $field['name']);

                }   // end field type == object
                else
                {
                    // standard form field
                    $this->setWidget($field['name'], CustomWidgetExtender::createSfWidget($field, $user, $this));
                    $this->widgetSchema->setLabel($field['name'], $field['label']);

                    if(trim($field['default']) != '')
                        $this->setDefault($field['name'], $field['default']);

                    // add field name to use_fields array
                    array_push($use_fields, $field['name']);                
                }   // end field type != object
            }

        }
    }

}

Solution

  • I ended up doing a rough hack by processing each form manually rather than trying to shoehorn this type of form into the symfony 1.x form framework.