4

I have a referenced_list in my ng-admin app:

nga.field('profiles', 'referenced_list') // display list of related profiles
                .targetEntity(profiles) 
                .targetReferenceField('user_id')
                .targetFields([
                    nga.field('id').isDetailLink(true),
                    nga.field('username'),
                ]),
            nga.field('', 'template').label('')
                .template('<span class="pull-right"><ma-filtered-list-button entity-name="profiles" filter="{ user_id: entry.values.id }" size="sm"></ma-filtered-list-button></span>')

The template field creates a "view all related profiles" link.

What I would like to do is create a "add new profile" button that links to the profile creation page, and pre-selects the current user_id.

Is there a hack to do this or a custom template / directive that can do this?

TimoSolo
  • 7,068
  • 5
  • 34
  • 50

1 Answers1

5

The <ma-create-button>directive has been added a few days ago (https://github.com/marmelab/ng-admin/pull/696). It allows exactly what you want:

<ma-create-button entity-name="comments" default-values="{ post_id: entry.values.id }" size="xs"></ma-create-button>

It's available in ng-admin 0.9-dev and higher.

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