The example works great for creating/editing a node with only a title. When adding in additional fields such as body, one might think to do the following:
@mkinnan I often use the same technique that you use with the data_to_save example. Essentially build a simple form, with simple inputs, then in the submit handler build the complex JSON that Drupal is expecting.
Is the approach I have taken below the correct method to handle form fields for node creation? Or am I missing something?
In attempting to create my own custom node add pages, I have reviewed the example: http://docs.drupalgap.org/7/Entities/Editing_Entities
The example works great for creating/editing a node with only a title. When adding in additional fields such as body, one might think to do the following:
The issue with that for the body form element is that when
hook_form_submit
is called, Drupal is expecting the format of form.values to be:but what is returned from my custom form is:
which causes the node creation to fail. So, instead I create a different identity for my body:
and rebuild the form.values object before passing to
node_save
: