0

I'm trying to figure out how I can make a custom directive which will combine:

  1. reference list select field
  2. create button which will show a reference entity creation view
  3. and on creation save. reload reference list entities, so i can choose a newly created entity.

It can be easily done using completely custom code, but i want to make it using ng-admin templates and directives.

It's also quite common functionality, but i'm having a hard time integrating it into ng-admin.

So in case there is no required field in list, i will not loose data i already entered by navigating to create new entity on another page.

ulikus
  • 186
  • 6

1 Answers1

0

Add two fields:

  • one of type referenced_list to display related entries
  • one virtual field with an empty label and a custom template, using a create button with prefilled default values for the related entry (e.g. <ma-create-button entity-name="comments" default-values="{ post_id: entry.values.id }" size="xs"></ma-create-button>)

Check https://github.com/marmelab/ng-admin-demo/blob/3a0944acbcb12dc20dc8a4a860c6c9f8da9c1645/js/customers/config.js#L81-L101 for an example.

François Zaninotto
  • 7,068
  • 2
  • 35
  • 56