neon-jungle/wagtailmodelchooser

Create button in modal

markfinger opened this issue · 2 comments

Hi.

Just wondering if you'd be open to a PR that added control over the display and href of a "Create" button within the instance-selection modal? Off the top of my head, I'm thinking of something like

def create_url(request):
    return '...'

@register_model_chooser(create_url=create_url)
class Foo(models.Model):
    # ...

I'm totally open to any suggestions you might have around the API, etc.

We'll need this functionality on a project, so if you're open to it, I can justify spending another hour or two to make it less hacky and send a PR. No worries, if you're reluctant or not enthused by the idea.

Cheers,
Mark.

Small aside: my implementation suggestion was made under the assumption that the modal would have a "Create" button, but it's entirely feasible that it might appear elsewhere within the UI. If so, I'd imagine that the wiring may occur at the field definition within the panel declaration.

seb-b commented

Hey I know I'm entirely too late, I just stumbled across your instance-selector which brought me back here. Looks like a good project!

If anyone else is looking into this, I'm definitely open to the idea of a create new link, they can usually be inferred if modeladmin is being used too which makes it nice and easy to generate