django-fobi icon indicating copy to clipboard operation
django-fobi copied to clipboard

Alternative to fobi_initial_data to provide initial values?

Open will-emmerson opened this issue 7 years ago • 4 comments

I need to be able to edit form submissions (I am using customized DBStoreHandlerPlugin), i.e. when viewing a form entry it needs to pick up previously entered data. I could theoretically do this by passing initial values to view_form_entry using fobi_initial_data but this isn't going to work for longer forms with text fields because of url length limit. Any advice on how I can do this without writing my own view? I'm guessing this might be a bit easier when class-based views are finished?

will-emmerson avatar May 01 '18 10:05 will-emmerson

@will-emmerson:

If you're not in hurry, wait until the CBVs are finished.

barseghyanartur avatar May 01 '18 10:05 barseghyanartur

That functionality works awesomely, the way we are doing it, (so users don’t see any crazy url for the initial data) Is when they click the button to edit the form data the url is constructed in JavaScript from a python dict passed into the view, then the JavaScript opens that url in an iframe (fancybox) to display the form data to edit, then no one sees weird urls.

jstacoder avatar May 15 '18 05:05 jstacoder

I'm thinking that when we have CBV ready, we could add alternative CBV views for viewing/submitting form in the db_store package, so that we could use those (over the default ones) if such functionality is needed).

barseghyanartur avatar May 15 '18 09:05 barseghyanartur

@barseghyanartur actually we did need to override how that was happeing, and using the cbvs we just had to redefine get_initial_data and it just worked, we have the data in our own model, which we pass an id to the view, so our get_initial_data is just: return DataModel.objects.get(id=self.kwargs.get('id')).data

jstacoder avatar Mar 27 '19 15:03 jstacoder