Skip to content

Commit

Permalink
Remove uneditable flag name field from conditions
Browse files Browse the repository at this point in the history
This change hides the flag name field from condition creation and edit forms. The field was not editable by users, because the flag name is always provided.

The field had been rendering as blank, despite having the value filled in. This change moves it to a hidden field.
  • Loading branch information
willbarton committed Feb 25, 2020
1 parent 9383d87 commit db513d5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
3 changes: 2 additions & 1 deletion wagtailflags/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ class FlagStateForm(forms.ModelForm):
label='Flag',
required=True,
disabled=True,
widget=forms.HiddenInput(),
)
condition = forms.ChoiceField(
label='Condition name',
label='Condition',
required=True
)
value = forms.CharField(
Expand Down
44 changes: 28 additions & 16 deletions wagtailflags/templates/wagtailflags/flags/edit_condition.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "wagtailadmin/base.html" %}
{% load i18n feature_flags %}
{% block titletag %}{% if form.instance %}Edit {{ form.instance.condition }}{% else %}Create condition{% endif %}{% endblock %}
{% block titletag %}{% if form.instance %}Edit {{ form.instance.condition }} condition{% else %}Create condition{% endif %}{% endblock %}

{% block content %}
{% include "wagtailadmin/shared/header.html" with title=flag.name icon="tag" %}
Expand All @@ -18,23 +18,35 @@ <h2 class="nice-padding">
{% endif %}
{% csrf_token %}
<ul class="fields">
<li class="actions">
{% for field in form %}
{% if field.errors %}
<div class="help-block help-critical" style="margin-top:0;">
{{ field.errors }}

{% for field in form %}
<li {% if field.field.required %}class="required"{% endif %}>
{% if not field.is_hidden %}
<div class="field">
{{ field.label_tag }}

<div class="field-content">
<div class="input">
{{ field }}
</div>
{% if field.help_text %}
<p class="help">{{ field.help_text|safe }}</p>
{% endif %}
</div>

{% if field.errors %}
<div class="help-block help-critical" style="margin-top:0;">
{{ field.errors }}
</div>
{% endif %}
</div>
{% else %}
{{ field }}
{% endif %}
<label>{{ field.label }}</label>
<div class="field-content">
<div class="input">
{{ field }}
<span></span>
</div>
<p class="help"></p>
</div>
{% endfor %}
</li>

</li>
{% endfor %}

<li class="actions">
<input class="button action-save button-longrunning" type="submit" value="Save condition" />
<a class="button bicolor icon icon-cog" href="{% url 'wagtailflags:flag_index' flag.name %}">Back to {{ flag.name }}</a>
Expand Down

0 comments on commit db513d5

Please sign in to comment.