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:
Will Rossiter 2009-04-27 00:20:20 +00:00
parent fc01169f69
commit a076630b9c
5 changed files with 43 additions and 48 deletions

View File

@ -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"
@ -77,7 +77,7 @@ class FieldEditor extends FormField {
}
return false;
}
/**
* Handles saving the page. Needs to keep an eye on fields
* and options which have been removed / added

View File

@ -6,34 +6,28 @@
/* Add a Field Menu
---------------------------------------- */
.MenuHolder {
color: #999;
color: #999;
border: 1px solid #ddd;
background: #f4f4f4;
overflow: hidden;
padding: 4px 10px;
}
.MenuHolder ul {
background: #e7e7e7;
border: 1px solid #c6c6c6;
padding: 8px;
.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;
}
.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;
border: 1px solid #c6c6c6;
}
.MenuHolder li.addField {
background: url(../../cms/images/add.gif) no-repeat center left;
padding-left: 20px;
text-transform: uppercase;
}
/* Options / Settings Area
---------------------------------------- */
.FormOptions {

View File

@ -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,8 +43,8 @@
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({
type: "GET",
@ -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

View File

@ -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,15 +13,9 @@
<% 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>
<% control FormOptions %>

View 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>