mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
MINOR: changed field adding to use a dropdown field rather the a list of links that was getting unmanagable with all the fields
This commit is contained in:
parent
fc01169f69
commit
a076630b9c
@ -66,7 +66,7 @@ class FieldEditor extends FormField {
|
|||||||
foreach($fields as $field => $title) {
|
foreach($fields as $field => $title) {
|
||||||
// get the nice title and strip out field
|
// get the nice title and strip out field
|
||||||
$niceTitle = trim(str_ireplace("Field", "", eval("return $title::\$singular_name;")));
|
$niceTitle = trim(str_ireplace("Field", "", eval("return $title::\$singular_name;")));
|
||||||
if($title != 'MultipleOptionField') {
|
if($niceTitle) {
|
||||||
$output->push(new ArrayData(array(
|
$output->push(new ArrayData(array(
|
||||||
'ClassName' => $field,
|
'ClassName' => $field,
|
||||||
'Title' => "$niceTitle"
|
'Title' => "$niceTitle"
|
||||||
|
@ -7,33 +7,27 @@
|
|||||||
---------------------------------------- */
|
---------------------------------------- */
|
||||||
.MenuHolder {
|
.MenuHolder {
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
border: 1px solid #ddd;
|
||||||
.MenuHolder ul {
|
|
||||||
background: #e7e7e7;
|
|
||||||
border: 1px solid #c6c6c6;
|
|
||||||
padding: 8px;
|
|
||||||
}
|
|
||||||
.MenuHolder li {
|
|
||||||
display: inline;
|
|
||||||
font-size: 11px;
|
|
||||||
padding: 2px 0;
|
|
||||||
}
|
|
||||||
.MenuHolder li a {
|
|
||||||
padding: 5px 4px 3px 4px;
|
|
||||||
font-weight: bold;
|
|
||||||
border: 1px solid transparent;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
.MenuHolder li a:hover {
|
|
||||||
background: #f4f4f4;
|
background: #f4f4f4;
|
||||||
border: 1px solid #c6c6c6;
|
overflow: hidden;
|
||||||
|
padding: 4px 10px;
|
||||||
}
|
}
|
||||||
.MenuHolder li.addField {
|
.MenuHolder h2 {
|
||||||
background: url(../../cms/images/add.gif) no-repeat center left;
|
float: left;
|
||||||
padding-left: 20px;
|
|
||||||
text-transform: uppercase;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.MenuHolder select {
|
||||||
|
float: left;
|
||||||
|
width: 240px;
|
||||||
|
margin: 7px 0 0 8px;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.MenuHolder .submit {
|
||||||
|
float: left;
|
||||||
|
margin: 7px 0 0 4px;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
/* Options / Settings Area
|
/* Options / Settings Area
|
||||||
---------------------------------------- */
|
---------------------------------------- */
|
||||||
.FormOptions {
|
.FormOptions {
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* area. the type information should all be on this object
|
* area. the type information should all be on this object
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$("div.FieldEditor ul.Menu li a").livequery('click',function() {
|
$("div.FieldEditor .MenuHolder .submit").livequery('click',function() {
|
||||||
|
|
||||||
// if this form is readonly...
|
// if this form is readonly...
|
||||||
if($("#Fields").hasClass('readonly')) return false;
|
if($("#Fields").hasClass('readonly')) return false;
|
||||||
@ -43,7 +43,7 @@
|
|||||||
var action = $("#Form_EditForm").attr("action") + '/field/Fields/addfield';
|
var action = $("#Form_EditForm").attr("action") + '/field/Fields/addfield';
|
||||||
var length = $(".FieldInfo").length + 1;
|
var length = $(".FieldInfo").length + 1;
|
||||||
var securityID = ($("#SecurityID").length > 0) ? '&SecurityID='+$("#SecurityID").attr("value") : '';
|
var securityID = ($("#SecurityID").length > 0) ? '&SecurityID='+$("#SecurityID").attr("value") : '';
|
||||||
var type = $(this).attr("ID");
|
var type = $(this).siblings("select").val();
|
||||||
|
|
||||||
//send ajax request to the page
|
//send ajax request to the page
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -69,7 +69,7 @@
|
|||||||
statusMessage(ss.i18n._t('UserForms.ERRORCREATINGFIELD', 'Error Creating Field'));
|
statusMessage(ss.i18n._t('UserForms.ERRORCREATINGFIELD', 'Error Creating Field'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
* Upon renaming a field we should go through and rename all the
|
* Upon renaming a field we should go through and rename all the
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
<div class="FieldEditor <% if isReadonly %>readonly<% end_if %>" id="Fields" name="$Name.Attr">
|
<div class="FieldEditor <% if isReadonly %>readonly<% end_if %>" id="Fields" name="$Name.Attr">
|
||||||
<div class="MenuHolder">
|
|
||||||
<ul class="TopMenu Menu">
|
<% include AddField %>
|
||||||
<li class="addField"><% _t('ADD', 'Add') %>:</li>
|
|
||||||
<% control CreatableFields %>
|
|
||||||
<li><a href="#" title="<% _t('ADD', 'Add') %> $Title" id="$ClassName">$Title</a></li>
|
|
||||||
<% end_control %>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="FieldListHold">
|
<div class="FieldListHold">
|
||||||
<ul class="FieldList" id="Fields_fields">
|
<ul class="FieldList" id="Fields_fields">
|
||||||
<% control Fields %>
|
<% control Fields %>
|
||||||
@ -18,14 +13,8 @@
|
|||||||
<% end_control %>
|
<% end_control %>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="MenuHolder">
|
|
||||||
<ul class="TopMenu Menu">
|
<% include AddField %>
|
||||||
<li class="addField"><% _t('ADD', 'Add') %>:</li>
|
|
||||||
<% control CreatableFields %>
|
|
||||||
<li><a href="#" title="<% _t('ADD', 'Add') %> $Title" id="$ClassName">$Title</a></li>
|
|
||||||
<% end_control %>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="FormOptions">
|
<div class="FormOptions">
|
||||||
<h3>Form Options</h3>
|
<h3>Form Options</h3>
|
||||||
|
12
templates/Includes/AddField.ss
Normal file
12
templates/Includes/AddField.ss
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<div class="MenuHolder">
|
||||||
|
<h2><% _t('ADD', 'Add') %></h2>
|
||||||
|
<select name="AddUserFormField" id="AddUserFormField">
|
||||||
|
<option value=""><% _t('SELECTAFIELD', 'Select a Field') %></option>
|
||||||
|
|
||||||
|
<% control CreatableFields %>
|
||||||
|
<option value="$ClassName">$Title</option>
|
||||||
|
<% end_control %>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<input type="submit" class="submit" value="<% _t('ADD', 'Add') %>" />
|
||||||
|
</div>
|
Loading…
Reference in New Issue
Block a user