Skip to content

Ability to place action buttons within fields #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ngirard opened this issue May 5, 2021 · 0 comments
Open

Ability to place action buttons within fields #118

ngirard opened this issue May 5, 2021 · 0 comments

Comments

@ngirard
Copy link

ngirard commented May 5, 2021

Hi,
let me start by expressing my gratitude for your efforts into this nice project !

When actions are related to a certain field, it makes sense to have their button rendered within that field.
See for instance:
Reset_password_example
("Mot de passe" meaning "Password" in French).

I've managed to make the "Reset password" button appear in the password field by dedicating the help_text to it:

class UserChangeForm(admin_forms.UserChangeForm):
    class Meta(admin_forms.UserChangeForm.Meta):
        model = User

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        password = self.fields.get('password')
        if password:
            password.help_text = \
                """<ul class="object-tools"><li class="objectaction-item" data-tool-name="reset_password">
                <a href="/admin/users/guest/3/actions/reset_password/" title="" class="">Reset password</a>
                </li></ul>
                """

Very hacky, but it hopefully provides you with a useful starting point for implementing this feature, would you consider it.

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant