I think if you embed the form under a different name (not
contact_details_id, try just contact details), that might fix it.

Right now what's happening is that the widgetschema
"contact_details_id" is being rendered with a value of 1, which makes
no sense, since it''s expecting an array as values. That leads me to
believe it's colliding with another widget that will be rendered with
the value of 1...

Daniel


On May 22, 4:06 am, Tofuwarrior <p...@clearintent.co.uk> wrote:
> Hi All,
>
> Anyone give me any pointers as to what might be the problem here, I'm
> new to embedded forms so am a bit stumped.
>
> I've got a form I'm embedding in the configure function below.
>
> When it gets used through the new action it works fine but when
> editing an existing record then it throws this error 'You must pass an
> array of values to render a widget schema'
>
> I've checked that the parent object has the MscdbContactDetails object
> the embedded form needs to populate the embedded form and am lost as
> to where else the problem might be.
>
> I've pasted the stack trace below.
>
> Can anyone help, deadline is looming :-(
>
> Cheers,
>
> TW
>
> public function configure()
>   {
>         unset(
>       $this['updated_at'],
>       $this['created_at']
>      );
>         $this->setWidget('project_id',new sfWidgetFormInputHidden());
>
>         if(!$this->getObject()->isNew()){
>                 $contact = $this->getObject()->getMscdbContactDetails();
>                 $contactForm = new MscdbContactDetailsForm($contact);
>         }else{
>                 $contactForm = new MscdbContactDetailsForm();
>         }
>
>         $this->embedForm('contact_details_id', $contactForm);
>
>         // project must be set in action
>           $project = $this->getObject()->getMscdbProject();
>
>           $query = MscdbStorytellerCategoryQuery::create()
>                  ->useMscdbProjectTellerCategoryLinkQuery()
>                    ->filterByMscdbProject($project)
>                  ->endUse();
>
>          $this->widgetSchema['storyteller_category_id'] = new
> sfWidgetFormPropelChoice(array(
>                   'model'     => 'MscdbStorytellerCategory',
>                   'criteria'  => $query,
>                   'add_empty' => false,
>                 ));
>
>          // $this->setWidget('storyteller_category_id', new
> sfWidgetFormPropelChoice(array('model' =>
> 'MscdbStorytellerCategory','criteria'=>$c, 'add_empty' => false)));
>
>         }
>
> STACK TRACE
>
>     * at ()
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/widget/
> sfWidgetFormSchema.class.php line 536 ...
>              533.
>              534.     if (!is_array($values) && !$values instanceof
> ArrayAccess)
>              535.     {
>              536.       throw new InvalidArgumentException('You must
> pass an array of values to render a widget schema');
>              537.     }
>              538.
>              539.     $formFormat = $this->getFormFormatter();
>     * at sfWidgetFormSchema->render('mscdb_storyteller[contact_details_id]', 
> 1, array(), null)
>
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/widget/
> sfWidgetFormSchemaDecorator.class.php line 61 ...
>               58.    */
>               59.   public function render($name, $values = array(),
> $attributes = array(), $errors = array())
>               60.   {
>               61.     return strtr($this->decorator, array('%content%'
> => $this->widget->render($name, $values, $attributes, $errors)));
>               62.   }
>               63.
>               64.   /**
>     * at 
> sfWidgetFormSchemaDecorator->render('mscdb_storyteller[contact_details_id]', 
> 1, array(), null)
>
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/widget/
> sfWidgetFormSchema.class.php line 512 ...
>              509.     $clone = clone $widget;
>              510.     $clone->setIdFormat($this->options['id_format']);
>
>              511.
>              512.     return $clone->render($this->generateName($name), 
> $value, array_merge($clone->getAttributes(),
>
> $attributes), $errors);
>              513.   }
>              514.
>              515.   /**
>     * at sfWidgetFormSchema->renderField('contact_details_id', 1,
> array(), null)
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/form/sfFormField.class.php
> line 119 ...
>              116.   {
>              117.     if ($this->parent)
>              118.     {
>              119.       return 
> $this->parent->getWidget()->renderField($this->name, $this->value, 
> $attributes, $this->error);
>
>              120.     }
>              121.     else
>              122.     {
>     * at sfFormField->render()
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/form/sfFormField.class.php
> line 58 ...
>               55.   {
>               56.     try
>               57.     {
>               58.       return $this->render();
>               59.     }
>               60.     catch (Exception $e)
>               61.     {
>     * at sfFormField->__toString()
>       in SF_ROOT_DIR/apps/frontend/modules/teller/templates/_form.php
> line 59 ...
>               56.         <th><?php echo 
> $form['contact_details_id']->renderLabel() ?></th>
>
>               57.         <td>
>               58.           <?php //echo 
> $form['contact_details_id']->renderError() ?>
>
>               59.           <?php echo $form['contact_details_id'] ?>
>               60.         </td>
>               61.       </tr>
>   62.
>     * at require('/mnt/Target01/338166/www.mostsignificantchange.com/
> web/apps/frontend/modules/teller/templates/_form.php')
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/view/sfPHPView.class.php
> line 75 ...
>               72.
>               73.     try
>               74.     {
>               75.       require($_sfFile);
>               76.     }
>               77.     catch (Exception $e)
>               78.     {
>     * at 
> sfPHPView->renderFile('/mnt/Target01/338166/www.mostsignificantchange.com/web/apps/frontend/modules/teller/templa...)
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/view/
> sfPartialView.class.php line 110 ...
>              107.       $this->getAttributeHolder()->set('sf_type',
> 'partial');
>              108.
>              109.       // render template
>              110.       $retval = 
> $this->renderFile($this->getDirectory().'/'.$this->getTemplate());
>
>              111.     }
>              112.     catch (Exception $e)
>              113.     {
>     * at sfPartialView->render()
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/helper/PartialHelper.php
> line 218 ...
>              215.   $view = new $class($context, $moduleName,
> $actionName, '');
>              216.   $view->setPartialVars(true ===
> sfConfig::get('sf_escaping_strategy') ?
> sfOutputEscaper::unescape($vars) : $vars);
>              217.
>              218.   return $view->render();
>              219. }
>              220.
>              221. /**
>     * at get_partial('form', array('form' =>
> object('MscdbStorytellerForm')))
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/helper/PartialHelper.php
> line 180 ...
>              177.  */
>              178. function include_partial($templateName, $vars =
> array())
>              179. {
>              180.   echo get_partial($templateName, $vars);
>              181. }
>              182.
>              183. /**
>     * at include_partial('form', array('form' =>
> object('MscdbStorytellerForm')))
>       in SF_ROOT_DIR/apps/frontend/modules/teller/templates/
> editSuccess.php line 3 ...
>                1. <h1>Edit Storyteller</h1>
>                2.
>                3. <?php include_partial('form', array('form' =>
> $form)) ?>
>    4.
>     * at require('/mnt/Target01/338166/www.mostsignificantchange.com/
> web/apps/frontend/modules/teller/templates/editSuccess.php')
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/view/sfPHPView.class.php
> line 75 ...
>               72.
>               73.     try
>               74.     {
>               75.       require($_sfFile);
>               76.     }
>               77.     catch (Exception $e)
>               78.     {
>     * at 
> sfPHPView->renderFile('/mnt/Target01/338166/www.mostsignificantchange.com/web/apps/frontend/modules/teller/templa...)
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/view/sfPHPView.class.php
> line 185 ...
>              182.       $this->attributeHolder->set('sf_type',
> 'action');
>              183.
>              184.       // render template file
>              185.       $content = 
> $this->renderFile($this->getDirectory().'/'.$this->getTemplate());
>
>              186.
>              187.       if (sfConfig::get('sf_cache') && null !==
> $uri)
>              188.       {
>     * at sfPHPView->render()
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/filter/
> sfExecutionFilter.class.php line 155 ...
>              152.         break;
>              153.
>              154.       case sfView::RENDER_CLIENT:
>              155.         $viewData = $view->render();
>              156.         
> $this->context->getResponse()->setContent($viewData);
>
>              157.         break;
>  158.
>     * at sfExecutionFilter->executeView('teller', 'edit', 'Success',
> array('MscdbProject' => object('MscdbProject'), 'form' =>
> object('MscdbStorytellerForm')))
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/filter/
> sfExecutionFilter.class.php line 116 ...
>              113.         return;
>              114.     }
>              115.
>              116.     $this->executeView($actionInstance->getModuleName(), 
> $actionInstance->getActionName(), $viewName,
>
> $actionInstance->getVarHolder()->getAll());
>              117.   }
>              118.
>              119.   /**
>     * at sfExecutionFilter->handleView(object('sfFilterChain'),
> object('tellerActions'), 'Success')
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/filter/
> sfExecutionFilter.class.php line 47 ...
>               44.       $timer->addTime();
>               45.       $timer =
> sfTimerManager::getTimer(sprintf('View "%s" for "%s/%s"', $viewName,
> $actionInstance->getModuleName(), $actionInstance->getActionName()));
>               46.
>               47.       $this->handleView($filterChain,
> $actionInstance, $viewName);
>               48.
>               49.       $timer->addTime();
>               50.     }
>     * at sfExecutionFilter->execute(object('sfFilterChain'))
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/filter/
> sfFilterChain.class.php line 53 ...
>               50.       }
>               51.
>               52.       // execute the next filter
>               53.       $this->chain[$this->index]->execute($this);
>               54.     }
>               55.   }
>   56.
>     * at sfFilterChain->execute()
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/filter/
> sfBasicSecurityFilter.class.php line 72 ...
>               69.     }
>               70.
>               71.     // the user has access, continue
>               72.     $filterChain->execute();
>               73.   }
>               74.
>               75.   /**
>     * at sfBasicSecurityFilter->execute(object('sfFilterChain'))
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/filter/
> sfFilterChain.class.php line 53 ...
>               50.       }
>               51.
>               52.       // execute the next filter
>               53.       $this->chain[$this->index]->execute($this);
>               54.     }
>               55.   }
>   56.
>     * at sfFilterChain->execute()
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/filter/
> sfRenderingFilter.class.php line 33 ...
>               30.   public function execute($filterChain)
>               31.   {
>               32.     // execute next filter
>               33.     $filterChain->execute();
>               34.
>               35.     // get response object
>               36.     $response = $this->context->getResponse();
>     * at sfRenderingFilter->execute(object('sfFilterChain'))
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/filter/
> sfFilterChain.class.php line 53 ...
>               50.       }
>               51.
>               52.       // execute the next filter
>               53.       $this->chain[$this->index]->execute($this);
>               54.     }
>               55.   }
>   56.
>     * at sfFilterChain->execute()
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/controller/
> sfController.class.php line 233 ...
>              230.       }
>              231.
>              232.       // process the filter chain
>              233.       $filterChain->execute();
>              234.     }
>              235.     else
>              236.     {
>     * at sfController->forward('teller', 'edit')
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/controller/
> sfFrontWebController.class.php line 48 ...
>               45.       }
>               46.
>               47.       // make the first request
>               48.       $this->forward($moduleName, $actionName);
>               49.     }
>               50.     catch (sfException $e)
>               51.     {
>     * at sfFrontWebController->dispatch()
>       in SF_ROOT_DIR/lib/vendor/symfony/lib/util/sfContext.class.php
> line 170 ...
>              167.    */
>              168.   public function dispatch()
>              169.   {
>              170.     $this->getController()->dispatch();
>              171.   }
>              172.
>              173.   /**
>     * at sfContext->dispatch()
>       in SF_ROOT_DIR/content/frontend_dev.php line 13 ...
>
> --
> If you want to report a vulnerability issue on symfony, please send it to 
> security at symfony-project.com
>
> 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 
> athttp://groups.google.com/group/symfony-users?hl=en

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

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