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) {
|
||||
// get the nice title and strip out field
|
||||
$niceTitle = trim(str_ireplace("Field", "", eval("return $title::\$singular_name;")));
|
||||
if($title != 'MultipleOptionField') {
|
||||
if($niceTitle) {
|
||||
$output->push(new ArrayData(array(
|
||||
'ClassName' => $field,
|
||||
'Title' => "$niceTitle"
|
||||
|
@ -7,33 +7,27 @@
|
||||
---------------------------------------- */
|
||||
.MenuHolder {
|
||||
color: #999;
|
||||
}
|
||||
.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 {
|
||||
border: 1px solid #ddd;
|
||||
background: #f4f4f4;
|
||||
border: 1px solid #c6c6c6;
|
||||
}
|
||||
.MenuHolder li.addField {
|
||||
background: url(../../cms/images/add.gif) no-repeat center left;
|
||||
padding-left: 20px;
|
||||
text-transform: uppercase;
|
||||
overflow: hidden;
|
||||
padding: 4px 10px;
|
||||
}
|
||||
.MenuHolder h2 {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.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
|
||||
---------------------------------------- */
|
||||
.FormOptions {
|
||||
|
@ -31,7 +31,7 @@
|
||||
* 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($("#Fields").hasClass('readonly')) return false;
|
||||
@ -43,7 +43,7 @@
|
||||
var action = $("#Form_EditForm").attr("action") + '/field/Fields/addfield';
|
||||
var length = $(".FieldInfo").length + 1;
|
||||
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
|
||||
$.ajax({
|
||||
@ -69,7 +69,7 @@
|
||||
statusMessage(ss.i18n._t('UserForms.ERRORCREATINGFIELD', 'Error Creating Field'));
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
/**
|
||||
* 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="MenuHolder">
|
||||
<ul class="TopMenu Menu">
|
||||
<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>
|
||||
|
||||
<% include AddField %>
|
||||
|
||||
<div class="FieldListHold">
|
||||
<ul class="FieldList" id="Fields_fields">
|
||||
<% control Fields %>
|
||||
@ -18,14 +13,8 @@
|
||||
<% end_control %>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="MenuHolder">
|
||||
<ul class="TopMenu Menu">
|
||||
<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>
|
||||
|
||||
<% include AddField %>
|
||||
|
||||
<div class="FormOptions">
|
||||
<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