Hi Chris, Having got stuck with the basics of populating and validating the form, I haven't got round to adding rows (dynamically or otherwise). I think I've got my head sufficiently around the book example to implement it now but I may yet decide to take the Javascript option. Meanwhile, I just ensure that there are more enough rows displayed.
Yes the book example is a lot of code (in particular that's a lot of logic for one action method) but maybe it can be turned into something reusable. Fantastic if it could... Regards, Mike On Nov 5, 4:07 pm, Chris <[email protected]> wrote: > Thanks for posting this. How have you solved the problem of > recreating the repeated fields on form validation error? For example, > I'm adding repeated fields via javascript, then we the form POST > occurs and validation fails, I need to figure out how to recreate > those fields in the form. The pylons book example, does solve the > problem, but it sure seems like a lot of code to write for every form > that has a nested structure. > > Has anybody got an elegant solution for recreating javascript-added > repeat fields when the form is invalid? > > The path I'm heading down is to just use ajax to submit the form. > This keeps the form intact. But now, I have to fill in the error > messages via javascript. Something like, > > 1. Initial GET, use htmlfill to fill in defaults or model obj values > 2. User adds extra repeatable fields via javascript, then submits via > jquery.form plugin > 3. Form validation fails, controller returns the formencode error dict > as JSON > 4. Javascript will fill in the error messages on the fields > > This works reasonably well, but I'm just wondering if anybody has a > better solution. > > Regards, > Chris > > On Nov 5, 6:38 am, "Mike Burrows (asplake)" <[email protected]> > wrote: > > > DRY'ed up my code, solution posted here:http://positiveincline.com/?p=540 > > > Thanks again, > > Mike --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" 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/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
