<div dir="ltr"><div><div class="gmail_extra"><div class="gmail_quote">2015-11-17 20:19 GMT+01:00 Nyall Dawson <span dir="ltr"><<a href="mailto:nyall.dawson@gmail.com" target="_blank">nyall.dawson@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class=""><p dir="ltr"><br>
On 17 Nov 2015 10:56 PM, "Alessandro Pasotti" <<a href="mailto:apasotti@gmail.com" target="_blank">apasotti@gmail.com</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> it seems that the widget's expression context does not have access to the currently edited record.<br>
><br>
> Maybe I've just not found a way to do that but it's impossible to filter relations with an expression built upon the the values of the "main" record (the one currently edited in the form) because $currentfeature refers to the relation layer, <br>
><br>
> A possible solution would be to add a $currentformfeature to the expression and add the edited feature to the expression context.<br>
><br>
> Would it be a possible solution? <br>
> Any hint?</p>
</span><p dir="ltr">I can't find the original discussion this relates too... What's the issue you're trying to solve?</p><span class=""><font color="#888888">
<p dir="ltr">Nyall</p>
</font></span><p dir="ltr"><span class=""></span></p></blockquote><div> <br></div></div><br></div><div class="gmail_extra">Hi,<br><br></div><div class="gmail_extra">when using QgsValueRelationWidget I would like to be able to filter the related items on the value from another column in the currently edited feature.<br><br></div><div class="gmail_extra">I need an expression in the related layer which is based on a value in the current feature, but in the context of the related layer <span class="">$currentfeature is not the feature currently being edited but the related feature.<br></span></div><div class="gmail_extra"></div><br></div>So, we need to pass the feature or the feature ID to the widget or (better) to the context, which is currently non possible since the call to  QgsValueRelationWidgetFactory::createCache populates the combo on widget init and cannot be changed.<br><div><div class="gmail_extra"><br></div><div class="gmail_extra">A possible solution is to add the currently edited feature informations to the context (currentFeatureContext or something similar) and then retrieve the feature information with <span class=""> $currentformfeature or the like.<br><br><br></span></div><div class="gmail_extra"><span class="">Suggestions welcome!<br><br></span></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature">Alessandro Pasotti<br>w3:   <a href="http://www.itopen.it" target="_blank">www.itopen.it</a></div>
</div></div></div>