diff --git a/src/sunstone/public/js/plugins/oneflow-templates.js b/src/sunstone/public/js/plugins/oneflow-templates.js
index f9759296d4..4038d157a4 100644
--- a/src/sunstone/public/js/plugins/oneflow-templates.js
+++ b/src/sunstone/public/js/plugins/oneflow-templates.js
@@ -24,13 +24,13 @@ var create_service_template_tmpl = '\
\
\
\
\
@@ -1244,7 +1244,8 @@ function setupCreateServiceTemplateDialog(){
$(".service_networks tbody").append(
'
\
| \
- \
+ \
+ '+ tr("Only word characters are allowed") + '\
| \
\
\
@@ -1404,17 +1405,18 @@ function setupCreateServiceTemplateDialog(){
add_role_tab(roles_index);
});
-
- $('#create_service_template_submit',dialog).click(function(){
- var json_template = generate_json_service_template_from_form();
- Sunstone.runAction("ServiceTemplate.create", json_template );
- return false;
- });
-
- $('#update_service_template_submit',dialog).click(function(){
- var json_template = generate_json_service_template_from_form();
- Sunstone.runAction("ServiceTemplate.update",service_template_to_update_id, JSON.stringify(json_template));
- return false;
+ $('#create_service_template_form',dialog).on('invalid', function () {
+ notifyError(tr("One or more required fields are missing or malformed."));
+ }).on('valid', function() {
+ if ($('#create_service_template_form',dialog).attr("opennebula_action") == "create") {
+ var json_template = generate_json_service_template_from_form();
+ Sunstone.runAction("ServiceTemplate.create", json_template );
+ return false;
+ } else if ($('#create_service_template_form',dialog).attr("opennebula_action") == "update") {
+ var json_template = generate_json_service_template_from_form();
+ Sunstone.runAction("ServiceTemplate.update",service_template_to_update_id, JSON.stringify(json_template));
+ return false;
+ }
});
$('#create_service_template_reset', dialog).click(function(){
@@ -1595,6 +1597,7 @@ function popUpCreateServiceTemplateDialog(){
dialog.die();
+ $("#create_service_template_form", dialog).attr("opennebula_action", "create");
$("#create_service_template_header", dialog).show();
$("#update_service_template_header", dialog).hide();
$("#create_service_template_submit", dialog).show();
@@ -1630,6 +1633,7 @@ function popUpUpdateServiceTemplateDialog() {
function fillUpUpdateServiceTemplateDialog(request, response){
var dialog = $('#create_service_template_dialog',dialogs_context);
+ $("#create_service_template_form", dialog).attr("opennebula_action", "update");
$("#create_service_template_header", dialog).hide();
$("#update_service_template_header", dialog).show();
$("#create_service_template_submit", dialog).hide();
|