Skip to content
Snippets Groups Projects
Commit e884acd3 authored by Benjamin Bertrand's avatar Benjamin Bertrand
Browse files

Hide interface name in create host form

The interface name doesn't need to be displayed in the form as we force
it to the hostname.

We set the interface name to the hostname when submitting the form.
This fixes the copy/paste issue with the mouse that didn't trigger the
keyup event.

JIRA INFRA-287
parent 3d275b7f
No related branches found
No related tags found
No related merge requests found
......@@ -69,14 +69,12 @@ $(document).ready(function() {
update_device_type_attributes();
});
// Prefill interface name with hostname
$("#name").keyup(function(event) {
var hostname = $(this).val();
// The interface name field is hidden in the create host form
// because it should be forced to the hostname
// Do that when submitting the form
$("#hostForm").submit(function(event) {
var hostname = $("#name").val();
$("#interface_name").val(hostname);
// If an invalid hostname was submitted, the interface name
// will be invalid as well
// Remove the invalid messages when starting typing a new name
$("#interface_name").removeClass("is-invalid");
});
// Fill MAC address on page load
......
......@@ -6,13 +6,13 @@
{% block hosts_main %}
<form id="hostForm" method="POST">
{{ form.hidden_tag() }}
{{ form.interface_name(type="hidden") }}
{{ render_field(form.name, class_="text-lowercase") }}
{{ render_field(form.device_type_id) }}
{{ render_field(form.description) }}
{{ render_field(form.item_id, disabled=True) }}
{{ render_field(form.network_id) }}
{{ render_field(form.ip) }}
{{ render_field(form.interface_name, class_="text-lowercase") }}
{{ render_field(form.random_mac) }}
{{ render_field(form.mac_address) }}
{{ render_field(form.cnames_string) }}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment