Skip to content

Commit

Permalink
Added value_template_string property to BaseInput
Browse files Browse the repository at this point in the history
To prevent the loss of original value passed to BaseInput sub-classes
due to overwrite in render method, the value is stored into
value_template_string property.
  • Loading branch information
monim67 committed Jan 20, 2020
1 parent 1d355c9 commit f396c20
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crispy_forms/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class BaseInput(TemplateNameMixin):

def __init__(self, name, value, **kwargs):
self.name = name
self.value = value
self.value_template_string = value
self.id = kwargs.pop('css_id', '')
self.attrs = {}

Expand All @@ -191,7 +191,7 @@ def render(self, form, form_style, context, template_pack=TEMPLATE_PACK, **kwarg
Renders an `<input />` if container is used as a Layout object.
Input button value can be a variable in context.
"""
self.value = Template(str(self.value)).render(context)
self.value = Template(str(self.value_template_string)).render(context)
template = self.get_template_name(template_pack)
context.update({'input': self})

Expand Down

0 comments on commit f396c20

Please sign in to comment.