Cool - glad it all got sorted out :) Ryan Weaver Lead Programmer Iostudio, LLC http://www.sympalphp.org http://www.thatsquality.com Twitter: @weaverryan
On Mon, Sep 20, 2010 at 10:27 AM, Robert Schoenthal <[email protected] > wrote: > He Ryan, > > unset($this->form['foo']); > > $this->form->getWidgetSchema()->offsetExists('foo'); //returns > false > $this->form->getValidatorSchema()->offsetExists('foo'); //returns > false > > Big Facepalm to me, these few lines above in my code, and still > getting no error on "foo" let me write a single encapsulated test for > that. > > and see...it worked as expected in my test, so there must be something > wrong with my code. > > and debugged my code, and found out that the removal of fields was > called in the wrong place... > I corrected it, and voila it worked as expected... > > /** > * unsets all fields defined in the configuration > * call it with: > * $this->unsetField($form->getWidgetSchema(),$form- > >getValidatorSchema(),$fieldToRemove); > * > * @param sfWidgetFormSchema $wschema > * @param sfValidatorSchema $vschema > * @param string $field "foo" | "foo/bar" | "foo/bar/bazz" > */ > protected function unsetField(sfWidgetFormSchema &$wschema, > sfValidatorSchema &$vschema, $field) > { > $field = $this->sanitizeFieldName($field); > > if(is_array($field) && $index = array_shift($field)) > { > if(count($field) && $wschema->offsetGet($index)) > { > $this->unsetField($wschema[$index],$vschema[$index],$field); > } > else > { > unset($wschema[$index]); > unset($vschema[$index]); > } > } > else > { > unset($wschema[$field]); > unset($vschema[$field]); > } > } > > thats the magic function to unset fields, it works also on embedded > forms...see the "field" parameter (::sanitizeField only splits foo/bar/ > bazz into an array ('foo','bar','bazz') if neccesary) > > so thanks for all da help, i couldnt think it wont work as i expect > it ;) > > greetz > robert > > -- > 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 developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<symfony-devs%[email protected]> > For more options, visit this group at > http://groups.google.com/group/symfony-devs?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 developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en
