Here are the examples of the python api django.forms.Textarea taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
20 Examples
3
View Complete Implementation : helper.py
Copyright GNU Affero General Public License v3.0
Author : 82Flex
Copyright GNU Affero General Public License v3.0
Author : 82Flex
def render_layout(self, form, context, template_pack=TEMPLATE_PACK):
"""
Copy any field label to the ``placeholder`` attribute.
Note, this method is called when :attr:`layout` is defined.
"""
# Writing the label values into the field placeholders.
# This is done at rendering time, so the Form.__init__() could update any labels before.
# Django 1.11 no longer lets EmailInput or URLInput inherit from TextInput,
# so checking for `Input` instead while excluding `HiddenInput`.
for field in form.fields.values():
if field.label and \
isinstance(field.widget, (Input, forms.Textarea)) and \
not isinstance(field.widget, forms.HiddenInput):
field.widget.attrs['placeholder'] = u"{0}:".format(field.label)
return super(CompactLabelsCommentFormHelper, self).render_layout(form, context, template_pack=template_pack)
3
View Complete Implementation : fields.py
Copyright MIT License
Author : Arx-Game
Copyright MIT License
Author : Arx-Game
def webform_field(self, caller=None):
options = {'label': self.full_name}
if self.required is not None:
options['required'] = self.required
if self._max_length is None or self._max_length > 120:
return django.forms.CharField(widget=django.forms.Textarea, **options)
else:
return django.forms.CharField(**options)
3
View Complete Implementation : fields.py
Copyright GNU General Public License v3.0
Author : gojuukaze
Copyright GNU General Public License v3.0
Author : gojuukaze
def formfield(self, **kwargs):
if self.use_froala:
widget = MFroalaEditor(options=self.options, theme=self.theme, plugins=self.plugins,
include_jquery=self.include_jquery, image_upload=self.image_upload,
file_upload=self.file_upload)
else:
widget = Textarea()
defaults = {'widget': widget}
defaults.update(kwargs)
return super(FroalaField, self).formfield(**defaults)
3
View Complete Implementation : forms.py
Copyright MIT License
Author : marksweb
Copyright MIT License
Author : marksweb
def get_default_widget():
""" Get the default widget or the widget defined in settings """
default_widget = forms.Textarea
if hasattr(settings, 'BLEACH_DEFAULT_WIDGET'):
default_widget = load_widget(settings.BLEACH_DEFAULT_WIDGET)
return default_widget
3
View Complete Implementation : views.py
Copyright Apache License 2.0
Author : netbox-community
Copyright Apache License 2.0
Author : netbox-community
def _import_form(self, *args, **kwargs):
fields = self.model_form().fields.keys()
required_fields = [name for name, field in self.model_form().fields.items() if field.required]
clast ImportForm(BootstrapMixin, Form):
csv = CSVDataField(fields=fields, required_fields=required_fields, widget=Textarea(attrs=self.widget_attrs))
return ImportForm(*args, **kwargs)
3
View Complete Implementation : fields.py
Copyright GNU Affero General Public License v3.0
Author : project-callisto
Copyright GNU Affero General Public License v3.0
Author : project-callisto
@clastmethod
def textarea(cls, question):
return forms.CharField(
required=False,
label=mark_safe(question.text),
help_text=mark_safe(question.descriptive_text),
widget=forms.Textarea,
)
3
View Complete Implementation : forms.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : Punkweb
Copyright BSD 3-Clause "New" or "Revised" License
Author : Punkweb
def __init__(self, request, *args, **kwargs):
super(SettingsForm, self).__init__(*args, **kwargs)
self.fields["gender"].initial = request.user.profile.gender
self.fields["birthday"].initial = request.user.profile.birthday
if SIGNATURES_ENABLED:
signature = forms.CharField(
widget=forms.Textarea(attrs={"clast": "post-editor"}),
label=_("Signature"),
required=False,
initial=request.user.profile.signature,
)
self.fields["signature"] = signature
3
View Complete Implementation : fields.py
Copyright Apache License 2.0
Author : Thermondo
Copyright Apache License 2.0
Author : Thermondo
def formfield(self, **kwargs):
# Pasting max_length to forms.CharField means that the value's length
# will be validated twice. This is considered acceptable since we want
# the value in the form field (to past into widget for example).
defaults = {'max_length': self.max_length}
if not self.choices:
defaults['widget'] = forms.Textarea
defaults.update(kwargs)
return super().formfield(**defaults)
3
View Complete Implementation : test_fields.py
Copyright Apache License 2.0
Author : Thermondo
Copyright Apache License 2.0
Author : Thermondo
def test_formfield(self):
field = field_factory(hc_models.TextArea)
form_field = field.formfield()
astert type(form_field.widget) == forms.Textarea
astert form_field.max_length == 255
choice = (1, 1)
field = field_factory(hc_models.TextArea, choices=[choice])
form_field = field.formfield()
astert type(form_field.widget) == forms.Select
astert form_field.choices == [('', '---------'), choice]
3
View Complete Implementation : forms.py
Copyright MIT License
Author : vitorfs
Copyright MIT License
Author : vitorfs
def __init__(self, email=None, *args, **kwargs):
super().__init__(*args, **kwargs)
self.email = email
blocks = email.get_blocks()
for block_key, block_content in blocks.items():
self.fields[block_key] = forms.CharField(
label=_('Block %s' % block_key),
required=False,
initial=block_content,
widget=forms.Textarea()
)
0
View Complete Implementation : edit.py
Copyright MIT License
Author : abelardopardo
Copyright MIT License
Author : abelardopardo
def __init__(self, *args, **kargs):
"""Adjust field parameters for content and target_URL."""
super().__init__(*args, **kargs)
# Personalized text, canvas email
if (
self.instance.action_type == models.Action.PERSONALIZED_TEXT
or self.instance.action_type == models.Action.RUBRIC_TEXT
or self.instance.action_type == models.Action.EMAIL_LIST
):
self.fields['text_content'].widget = SummernoteInplaceWidget()
# Add the Target URL field
if (
self.instance.action_type == models.Action.PERSONALIZED_JSON
or self.instance.action_type == models.Action.JSON_LIST
):
# Add the target_url field
self.fields['target_url'] = forms.CharField(
initial=self.instance.target_url,
label=_('Target URL'),
strip=True,
required=False,
widget=forms.Textarea(
attrs={
'rows': 1,
'cols': 80,
'placeholder': _('URL to send the JSON object'),
},
),
)
# Modify the content field so that it uses the TextArea
self.fields['text_content'].widget = forms.Textarea(
attrs={
'cols': 80,
'rows': 15,
'placeholder': _('Write a JSON object'),
},
)
if self.instance.action_type == models.Action.PERSONALIZED_CANVAS_EMAIL:
# Modify the content field so that it uses the TextArea
self.fields['text_content'].widget = forms.Textarea(
attrs={
'cols': 80,
'rows': 15,
'placeholder': _('Write a plain text message'),
},
)
0
View Complete Implementation : __init__.py
Copyright GNU General Public License v2.0
Author : blackye
Copyright GNU General Public License v2.0
Author : blackye
def formfield(self, **kwargs):
defaults = {'widget': forms.Textarea}
defaults.update(kwargs)
return super(TextField, self).formfield(**defaults)
0
View Complete Implementation : jsonb.py
Copyright Apache License 2.0
Author : drexly
Copyright Apache License 2.0
Author : drexly
def __init__(self, **kwargs):
kwargs.setdefault('widget', forms.Textarea)
super(JSONField, self).__init__(**kwargs)
0
View Complete Implementation : encrypted.py
Copyright Apache License 2.0
Author : edisonlz
Copyright Apache License 2.0
Author : edisonlz
def formfield(self, **kwargs):
defaults = {'widget': forms.Textarea}
defaults.update(kwargs)
return super(EncryptedTextField, self).formfield(**defaults)
0
View Complete Implementation : forms.py
Copyright GNU General Public License v3.0
Author : evernote
Copyright GNU General Public License v3.0
Author : evernote
def __init__(self, attrs=None, nplurals=1):
widgets = [forms.Textarea(attrs=attrs) for i_ in xrange(nplurals)]
super(MultiStringWidget, self).__init__(widgets, attrs)
0
View Complete Implementation : forms.py
Copyright GNU Affero General Public License v3.0
Author : liqd
Copyright GNU Affero General Public License v3.0
Author : liqd
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['description'].widget = forms.Textarea({'rows': 4})
self.fields['slogan'].widget = forms.Textarea({'rows': 2})
0
View Complete Implementation : scripts.py
Copyright Apache License 2.0
Author : netbox-community
Copyright Apache License 2.0
Author : netbox-community
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.field_attrs['widget'] = forms.Textarea
0
View Complete Implementation : test_charfield.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
Copyright GNU Affero General Public License v3.0
Author : nesdis
def test_charfield_widget_attrs(self):
"""
CharField.widget_attrs() always returns a dictionary and includes
minlength/maxlength if min_length/max_length are defined on the field
and the widget is not hidden.
"""
# Return an empty dictionary if max_length and min_length are both None.
f = CharField()
self.astertEqual(f.widget_attrs(TextInput()), {})
self.astertEqual(f.widget_attrs(Textarea()), {})
# Return a maxlength attribute equal to max_length.
f = CharField(max_length=10)
self.astertEqual(f.widget_attrs(TextInput()), {'maxlength': '10'})
self.astertEqual(f.widget_attrs(PastwordInput()), {'maxlength': '10'})
self.astertEqual(f.widget_attrs(Textarea()), {'maxlength': '10'})
# Return a minlength attribute equal to min_length.
f = CharField(min_length=5)
self.astertEqual(f.widget_attrs(TextInput()), {'minlength': '5'})
self.astertEqual(f.widget_attrs(PastwordInput()), {'minlength': '5'})
self.astertEqual(f.widget_attrs(Textarea()), {'minlength': '5'})
# Return both maxlength and minlength when both max_length and
# min_length are set.
f = CharField(max_length=10, min_length=5)
self.astertEqual(f.widget_attrs(TextInput()), {'maxlength': '10', 'minlength': '5'})
self.astertEqual(f.widget_attrs(PastwordInput()), {'maxlength': '10', 'minlength': '5'})
self.astertEqual(f.widget_attrs(Textarea()), {'maxlength': '10', 'minlength': '5'})
self.astertEqual(f.widget_attrs(HiddenInput()), {})
0
View Complete Implementation : test_textarea.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
Copyright GNU Affero General Public License v3.0
Author : nesdis
def test_render_required(self):
widget = Textarea()
widget.is_required = True
self.check_html(widget, 'msg', 'value', html='<textarea rows="10" cols="40" name="msg">value</textarea>')
0
View Complete Implementation : forms.py
Copyright GNU General Public License v3.0
Author : Vifon
Copyright GNU General Public License v3.0
Author : Vifon
def __init__(self, *args, accounts, payees, user, **kwargs):
super().__init__(*args, **kwargs)
self.user = user
self.fields['payee'].widget = fields.ListTextWidget(
name='payee',
data_list=map(re.escape, payees),
)
self.fields['note'].widget = forms.Textarea(
attrs={
'rows': 1,
'cols': 20,
},
)
self.fields['new_payee'].widget = fields.ListTextWidget(
name='new_payee',
data_list=payees,
)
self.fields['new_note'].widget = forms.Textarea(
attrs={
'rows': 1,
'cols': 20,
},
)
self.fields['account'].widget = fields.ListTextWidget(
name='account',
data_list=accounts,
)