Hello im trying to use the Image field widget in a custom form.
My goal is to then upload the image to my drupal site and add insert it in a node image field.
I see the image field widget working in the user profile edit form and also at the Article node type form.
However for some reason the image widget is not being rendered at my custom form.
Im using this code at the form implementation funciton:

form.elements['picture'] = {
      "type":"image",
      "widget_type":"imagefield_widget",
      "title":"Picture",
      "required":false,
      "value":"Add Picture"
    };

The rest of the form works as expected, other select and textfields widgets, the submit function, everithing works, except the image widget is not showing at all.
Im i missing something here?
Thank you for your help.

Comments

x7ian created an issue. See original summary.

x7ian’s picture

Issue summary: View changes
tyler.frankenstein’s picture

Version: 7.x-1.16 » 7.x-1.x-dev
Component: Module Code » Mobile Application Development Kit Code
Category: Support request » Feature request
Priority: Major » Normal

Hello @x7ian,

The image field widget in DrupalGap is only smart enough to handle image fields on entities (and the user profile picture) on the built in entity forms. When building a custom form, the widget isn't smart enough to recognize it's placement in a custom form. For now, developers will need to build a their own custom widget to collect the File/Image from the user within their app. After that, developers can just call jDrupal's file_save() function to get the file id, at which point you can attach that to an entity's field or whatever.

x7ian’s picture

Thank you for your help,
Is there anywhere where i can find examples of the usage of the file_save() function?
Can find it in the documentaiton