We have a drupalgap project in which we would like to utilize the entity autocomplete option for users to be able to find entities within the site. Do you have any thoughts on how to set up an autocreate option if the entity does not exist in the first place?

Comments

aliensun created an issue. See original summary.

aliensun’s picture

tyler.frankenstein’s picture

Title: Entity Autocreate » Support Entityreference Autocreate
Status: Active » Needs work
  1. Create a git repo called entityreference_autocreate
  2. Add a entityreference_autocreate.js file to it
  3. Implement hook_form_alter() to detect entity edit forms
  4. Iterate over fields on the form, detecting entity reference fields, take note of them
  5. Make a backup for the submit handlers on the current form
  6. Overwrite the submit handlers with a custom submit handler
  7. In this submit handler, use the jDrupal API to create the entity for the desired field
  8. then stick the newly created entity id into the form state values
  9. when all entities have been create, let the form submission handlers you set aside, run as usual