This question has been flagged
1 Reply
5870 Views

In version 10, i created Custom widget that enabled attaching an Google map to the model which had an field for latitude and another one for longitude. Widget used to be initialized like this:

<widget type="gmaps_widget"
        style="{'width': '100%','height': '300px'}"
        options="{'latitude':'address_latitude','longitude':'address_longitude'}"/>

address_latitude and address_longitude are actually names of Float fields on model.

Inside widgets init method i had following way to extract parameter passed via options attribute:

init(parent, node) {
    var options = pyeval.py_eval(node.attrs.options || '{}');
    ..... }


Since in v11 Widget is rendered from BasicRenderer which passes record as a 2nd argument to constructor instead of node, what would be the right way to obtain parameters from view? Traversing whole arch from parent widget seams too bad choice.

Documentation and comments doesn't say anything about parameters, it only shows how to add new widget to widgetRegistry.

Avatar
Discard
Best Answer

You are totally right. I need to fix that.  

I wanted to actually introduce the concept of AbstractViewWidget, and make AbstractField inherit from that new class.  Also, each widget in the widget registry should then be a subclass of AbstractViewWidget.  We could this way define a nice API for widgets in views.  For example, a updateState method.  I'll do that someday, but this will be in master.

Avatar
Discard