Hi Daniel, Thanks a million for replying, don't know what I would do without help from people on these boards!
I tried it but unfortunately it didn't work, the embedded form doesn't show, it reverts back to the propelChoice widget that is set in the default config. What I don't get is how it works for a new object but not for an existing one, I guess this is a clue as to where the problem is, do you have any other ideas or can you point me towards where I should look at what is going on? Paul On May 22, 5:15 pm, Richtermeister <nex...@gmail.com> wrote: > 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/ > > ... > > read more » -- 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