Submit/edit form tweaks

* Don't specify action on form - this is best practice and avoids the
  need to have separate form tags for submit and edit
* Add a short introduction to the submit form
* Focus first field on load only if first field is empty (avoids doing
  this focusing on the edit form which is not really useful).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2013-02-28 13:57:04 +00:00
parent a8ae70a600
commit 482abdcc8a
3 changed files with 14 additions and 4 deletions

View File

@ -30,14 +30,14 @@
</div> </div>
{% endblock %} {% endblock %}
{% block formtag %} {% block formtop %}
{% if form.was_saved %} {% if form.was_saved %}
<div class="alert alert-success"> <div class="alert alert-success">
Changes saved successfully. Changes saved successfully.
</div> </div>
{% endif %} {% endif %}
<form id="edit_layer_form" action="{% url edit_layer form.instance.name %}" method="post">
{% endblock %} {% endblock %}
<form id="edit_layer_form" method="post">
{% csrf_token %} {% csrf_token %}
{% for hidden in form.hidden_fields %} {% for hidden in form.hidden_fields %}
{{ hidden }} {{ hidden }}
@ -235,6 +235,10 @@
$('#addanothermaintainer').click(expand_maintainer) $('#addanothermaintainer').click(expand_maintainer)
$('#id_vcs_url').change(auto_web_fields) $('#id_vcs_url').change(auto_web_fields)
firstfield = $("#edit_layer_form input:text, #edit_layer_form textarea").first();
if( ! firstfield.val() )
firstfield.focus()
}); });
</script> </script>
{% endblock %} {% endblock %}

View File

@ -72,6 +72,10 @@ padding: 8px;
margin: 0px; margin: 0px;
} }
.submitformintro {
padding-bottom: 0.75em;
}
.formfields input { .formfields input {
width: 50%; width: 50%;
} }

View File

@ -21,8 +21,10 @@
{% endblock %} {% endblock %}
{% block formtag %} {% block formtop %}
<form id="edit_layer_form" action="{% url submit_layer %}" method="post"> <div class="submitformintro">
<p>Please enter the details for the layer you wish to add to the index.</p>
</div>
{% endblock %} {% endblock %}
{% block submitbuttons %} {% block submitbuttons %}