Skip to content
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

support for handling additional, non-descript, attribute properties t… #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

actongorton
Copy link

…o the buttons

I needed a way to have actions take place in a new browser window, but since I may want to have other attributes in the future, seemed to me that being able to add generic attribute tags could be useful for other things.

For example, if my action is named validate_ercd, then I can now add an attribute like so:

def get_validate_ercd_attr(self, obj):
    return 'formtarget="_blank"'

This causes the record to be opened in a new browser window instead of the current browser window.

@escaped
Copy link
Owner

escaped commented Dec 30, 2018

HI @actongorton,

thanks for your contribution. I think this could be a nice addition for some special use case. But I would prefer if the method returns a dictionary of attributes instead of a single string. This ensures, that the final rendered attributes are always in the correct format and errors like missing " are prevented.

def get_validate_ercd_attrs(self, obj):
    return {
        'target': '_blank',
    }

What do you think about that? If you like the idea, could you please update your PR and add some test cases that ensure the final HTML-tag is rendered correctly?

Thanks :)

@actongorton
Copy link
Author

actongorton commented Jan 4, 2019 via email

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

Successfully merging this pull request may close these issues.

3 participants