-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Is it possible to have different button bar depending on the form #262
Comments
hello @julienfumey thank you for using the martor package. MARTOR_TOOLBAR_BUTTONS = [
'bold', 'italic', 'horizontal', 'heading', 'pre-code',
'blockquote', 'unordered-list', 'ordered-list',
'link', 'image-link', 'image-upload', 'emoji',
'direct-mention', 'toggle-maximize', 'help'
] |
Hello @agusmakmun, Thanks for your answer. |
hmm interesting, for now not supported yet. But let's try to this solution: # widgets.py
from martor.widgets import MartorWidget
class CustomMartorWidget(MartorWidget):
def __init__(self, *args, **kwargs):
settings.MARTOR_TOOLBAR_BUTTONS = ['bold', 'italic', 'horizontal', 'heading'] # forms.py
from martor.widgets import MartorWidget
from yourapp.widgets import CustomMartorWidget
class CustomVisitorForm(forms.CharField):
def __init__(self, *args, **kwargs):
# to setup the editor without label
if not MARTOR_ENABLE_LABEL:
kwargs["label"] = ""
super().__init__(*args, **kwargs)
if not issubclass(self.widget.__class__, MartorWidget):
self.widget = CustomMartorWidget()
class VisitorForm(forms.ModelForm):
comment = CustomVisitorForm() If above still not working, for the quick solution you can use the JavaScript to hide some of the buttons, |
Hey,
I want to use martor on different forms of my websites. One of the form I want to use it on is a public form for which I would like to restrict the number of features (like removing the image upload button). But I want to keep those features for all the other forms.
Is there a way to change the configuration of the button bar on a specific form?
The text was updated successfully, but these errors were encountered: