What I’m trying to do
I’m working with the Form Generator example from @movelabs.
This app generates a Form based on a text definition.
Currently the app does not support generating images in the Form, and I want to add that functionallity.
I have a table with 3 text fields and and Image I uploaded directly to the table.
Following the logic of the application, I added the required parts for displaying the image, and apparently in the Form, the element for the image appears, but without contents.
Doing a bit of manual debugging, I get to the point in which I think that what is arriving as the content for the image is <anvil.LazyMedia object>, which is what I get when I call :
self.item = dict(anvil.server.call(‘get_contents_byId’,self.item_id))
to get the contents of the row of the database.
I’m stuck here because I don’t know how to transform this reference into the real image and pass that to the form_builder function.
Basically in the form_builder function:
input = FormInput(**entry)
Passes the dictionary (entry) with the table row to the FormInput Class
And this is what it is returned:
input.value = initial_data.get(entry[‘key’], None)
For the text fields input.value is the contents of the corresponding database field.
But for the image fields it is <anvil.LazyMedia object>
In the FormInput I again assing the contents for when the type is image:
elif self.type == "image": self.input = Image(source=key)
And again what I’m assigning is <anvil.LazyMedia object>
How can I get the image instead of the reference (or get the image from the reference) and pass that to the Form instead of the reference itself? In a regular Form within the editor I would do this using a data binding like this:
, but here I don’t know how to translate what I have into that.
I’ll appreciate your advice in how to achieve this.
Here is the app for you to check firsthand.