mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 15:05:42 +00:00
FIX: if type has not been selected, do not attempt to create a new field
This commit is contained in:
parent
b096cf611a
commit
6f1f3a2c40
@ -116,18 +116,19 @@
|
|||||||
*/
|
*/
|
||||||
$('div.FieldEditor .MenuHolder .action').entwine({
|
$('div.FieldEditor .MenuHolder .action').entwine({
|
||||||
onclick: function(e) {
|
onclick: function(e) {
|
||||||
|
var form = $("#Form_EditForm"),
|
||||||
|
length = $(".FieldInfo").length + 1,
|
||||||
|
fieldType = $(this).siblings("select").val(),
|
||||||
|
formData = form.serialize()+'NewID='+ length +"&Type="+ fieldType,
|
||||||
|
fieldEditor = $(this).closest('.FieldEditor');
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if($("#Fields").hasClass('readonly')) {
|
|
||||||
|
if($("#Fields").hasClass('readonly') || !fieldType) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// variables
|
|
||||||
var form = $("#Form_EditForm");
|
|
||||||
var length = $(".FieldInfo").length + 1;
|
|
||||||
var fieldType = $(this).siblings("select").val();
|
|
||||||
var formData = form.serialize()+'NewID='+ length +"&Type="+ fieldType;
|
|
||||||
var fieldEditor = $(this).closest('.FieldEditor');
|
|
||||||
|
|
||||||
// Due to some very weird behaviout of jquery.metadata, the url have to be double quoted
|
// Due to some very weird behaviout of jquery.metadata, the url have to be double quoted
|
||||||
var addURL = fieldEditor.attr('data-add-url').substr(1, fieldEditor.attr('data-add-url').length-2);
|
var addURL = fieldEditor.attr('data-add-url').substr(1, fieldEditor.attr('data-add-url').length-2);
|
||||||
|
|
||||||
@ -138,7 +139,9 @@
|
|||||||
data: formData,
|
data: formData,
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
$('#Fields_fields').append(data);
|
$('#Fields_fields').append(data);
|
||||||
|
|
||||||
statusMessage(userforms.message('ADDED_FIELD'));
|
statusMessage(userforms.message('ADDED_FIELD'));
|
||||||
|
|
||||||
var name = $("#Fields_fields li.EditableFormField:last").attr("id").split(' ');
|
var name = $("#Fields_fields li.EditableFormField:last").attr("id").split(' ');
|
||||||
|
|
||||||
$("#Fields_fields select.fieldOption").append("<option value='"+ name[2] +"'>New "+ name[2] + "</option>");
|
$("#Fields_fields select.fieldOption").append("<option value='"+ name[2] +"'>New "+ name[2] + "</option>");
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if canEdit %>
|
<% if canEdit %>
|
||||||
<div class="MenuHolder">
|
<div class="MenuHolder no-change-track">
|
||||||
<h2><% _t('ADD', 'Add') %></h2>
|
<h2><% _t('ADD', 'Add') %></h2>
|
||||||
|
|
||||||
<select name="AddUserFormField" id="AddUserFormField">
|
<select name="AddUserFormField" id="AddUserFormField">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user