You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am following the readme about Formsets with CrispyForms and have one question in relation to example:
class ExampleFormSetHelper(FormHelper):
def __init__(self, *args, **kwargs):
super(FormHelper, self).__init__(*args, **kwargs)
self.form_method = 'post'
self.layout = Layout(
HTML('{% if forloop.first %} Only display text on the first iteration... {% endif %}'),
Fieldset('Item: {{forloop.counter}}', 'field'),
'favorite_color',
'favorite_food',
)
self.add_input(Submit('submit', 'Save'))
Particularly - HTML('{% if forloop.first %} Only display text on the first iteration... {% endif %}'),
Is there any way to use this forloop for rendering just values of QuerySet which is sent to form as context, something like:
HTML('{% MyQuerySet.forloop.counter %}
I just need to add textual captions of the QuerySet to the form.. See the screenshot example.
The code i use for helper layout
class ProbesFormHelper(FormHelper):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.label_class = "d-none"
self.form_method = 'POST'
self.layout = Layout(
Row(
Field('probe', css_class='form-group col-md-12 mb-0 d-none'),
Column('value', css_class='form-group col-md-1 mb-0'),
Column('inUse', css_class='form-group col-md-2 mb-0'),
HTML('{{ probes }}'), #HERE i try to render out context 'probes' - need the textual value
css_class="form-row align-items-center"
),
)
self.form_tag = False
self.render_required_fields = True
Or maybe there is a way to render individual form items from formset in template somehow, so i can build layout here and use one 'SUBMIT' for all of them?
The text was updated successfully, but these errors were encountered:
Hello!
I am following the readme about Formsets with CrispyForms and have one question in relation to example:
Particularly -
HTML('{% if forloop.first %} Only display text on the first iteration... {% endif %}'),
Is there any way to use this forloop for rendering just values of QuerySet which is sent to form as context, something like:
HTML('{% MyQuerySet.forloop.counter %}
I just need to add textual captions of the QuerySet to the form.. See the screenshot example.
The code i use for helper layout
Or maybe there is a way to render individual form items from formset in template somehow, so i can build layout here and use one 'SUBMIT' for all of them?
The text was updated successfully, but these errors were encountered: