Closed dwasyl closed 2 years ago
@dwasyl:
I think I've done that once by embedding into the view.
The pseudo code would look as follows:
from fobi.views import view_form_entry
def my_view_form_entry(request, form_entry_slug, theme=None, template_name=None):
altered_request = request.copy() # pseudo code, somehow copy request object
# make it mutable
# If some condition, do alter request data (set your initial values here).
# then return original fobi view
return view_form_entry(altered_request, form_entry_slug, theme=theme, template_name=template_name)
@barseghyanartur Thanks, that makes sense, where I'm having trouble though, is what exactly to add to the request data. I've gone through a lot of the fobi
code and can't see an obvious way of adding a post variable to cause the right 'pre-loading'.
Further, I need the system to always open that same version of the form (i.e. the form associated with that FK), but I can't quite see how it would work for that at this point.
Any extra pointers oh how to embed an initial value before the form is even created?
Hi dwasyl, I used the modelobject as a starting point for a prefilled field to fill in ldap-data for e-mail and names in read-only-fields from the authentication. these Formfield types are very modular (thnx @barseghyanartur ;) ) so you could just copy such a module and modify it to your needs.
Karl
The docs mention that you can provide initial dynamic values only for text fields. Is it possible to provide the same for model object fields?
My use-case is that I have a multiple objects for which I have to collect associated data. I have multiple forms and the option to fill out one of each form associated with the object.
I.e. Form1 Form2 Form3
Object1 has Form1 and Form3 Object2 has Form1 Object3 has Form2 and Form3
To simplest option seems to be embedding the forms into views that I provide the object through the URL, but with each form I need to background include the associated object.
Is there an easy way to accomplish this?