I now realize part of my problem... when I create the new form, I use an object in the form constructor, thus all the values are available via the getObject() function. But since I am trying to build a query dynamically based on form data in the configure() function, this infomation is not yet available when I use the generated action code from Symfony (where it creates the form, then binds the request data to the form).
I somehow need to populate my choice widget with data based on the article_id set in the form after the bind() takes place. Is this possible out of hte box or should I extend my form object somehow? On Aug 16, 9:57 am, Jonotron <[email protected]> wrote: > http://gist.github.com/527267 > > (my wording above was slightly incorrect, but the problem is still the > same) > > The $this->getObject()->getArticleId() fails if the form is invalid > (by some other field). > > Each article has a number of categories that are entries are permitted > to use (hence the ArticleCategories model), and I create the form from > a new entry object with the an existing article object attached. > > So the query I define for the sfWidgetFormDoctrineChoice needs an > Article ID which I believe I should be able to retrieve from the form, > but I can't retrieve the Article ID value from the form when the form > is invalid. I've tried the sfForm::getValue() method and it returns an > empty array when the form is invalid. > > On Aug 13, 6:35 pm, Gustavo Adrian <[email protected]> > wrote: > > > Could you post the code from your form? > > > On Fri, Aug 13, 2010 at 7:36 PM, Jonotron <[email protected]> wrote: > > > I have a form that uses a sfWidgetFormDoctrineChoice widget and I pass > > > a query to it that selects my "category" records based on another > > > hidden field. My query has a ->where('a.id = ?', $this->getObject()- > > > >getCategoryId()); > > > > This works great when I am looking at the new form (as I create the > > > form from a new object). > > > > But when the form tries to validate and fails, my choice widget does > > > not render. It appears as though I cannot call sfForm->getObject() > > > after the sfForm->bind() function is called. In searching it appears > > > as though there isn't a way to grab the form values when it is > > > invalid. > > > > Is there a better way to solve what I'm trying to do, or am I missing > > > something obvious here? > > > > -- > > > 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 [email protected] > > > To unsubscribe from this group, send email to > > > [email protected]<symfony-users%[email protected]> > > > For more options, visit this group at > > >http://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 [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-users?hl=en
