Hello, I'm looking for some advice for using a graphic with a featureForm in a widget I'm developing please.
The featureForm documentation says that you can use a graphic as the featureForm.feature property, but I have not been able to get the form to display if I use a graphic. What are the requirements for a graphic for the form to display?
The background is that I'm trying to replicate behaviour in the Edit widget, where a graphic? is created and then you can set the attributes in a form, so the user gets the option to save or discard before a feature is actually saved to the layer. All the featureForm samples I've looked at use features that have already been saved in a layer.
In my case I'm creating a geometry by copy/union features in other layers, putting that geometry in graphic to display on the map (using the default graphics layer). I would like to use the graphic with the feature form, but I haven't been able to get it to display - I've tried adding attributes, falsely associating the graphic with the target layer via its layer property, wrapping in a feature, etc.
As a work around I'm creating a temporary featureLayer for editing (copying fields etc. from my target layer), saving the graphic to the temporary featureLayer, and then querying the temporary layer to get a feature for featureForm.feature (which can then be discarded or saved to the target layer). Whilst this works ok, doesn't seem like the best solution!
Thanks for any help.
You said "I've tried [...] falsely associating the graphic with the target layer via its layer property", so I assume you have something like this:
graphic.layer = layer;
Perhaps try with this additional line:
graphic.layer = layer;
graphic.sourceLayer = layer;
Note that sourceLayer is an undocumented property, and could be changed or removed in a future release without notice, so use at your own risk.