mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 15:05:42 +00:00
FEATURE: allow subclassing of editable form field to update the UDF form editor
This commit is contained in:
parent
53390d6a5d
commit
b1a0026d05
@ -290,6 +290,7 @@ class UserDefinedForm_Controller extends Page_Controller {
|
||||
// set the name of the form
|
||||
$form = new Form( $this, "Form", $fields, $actions, new RequiredFields( $required ) );
|
||||
$form->loadDataFrom($this->failover);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,7 @@ class EditableCheckbox extends EditableFormField {
|
||||
}
|
||||
|
||||
function getFilterField() {
|
||||
return new OptionsetField( $this->Name,
|
||||
$this->Title,
|
||||
return new OptionsetField( $this->Name, $this->Title,
|
||||
array( '-1' => '('._t('EditableCheckbox.ANY', 'Any').')',
|
||||
'on' => _t('EditableCheckbox.SELECTED', 'Selected'),
|
||||
'0' => _t('EditableCheckbox.NOTSELECTED', 'Not selected') )
|
||||
|
@ -206,10 +206,5 @@ class EditableFormField extends DataObject {
|
||||
function CustomParameter() {
|
||||
return $this->CustomParameter;
|
||||
}
|
||||
/*
|
||||
function saveInto( DataObject $record ) {
|
||||
if(
|
||||
}
|
||||
*/
|
||||
}
|
||||
?>
|
@ -48,6 +48,36 @@ class FieldEditor extends FormField {
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a DataObjectSet of all the addable fields to populate
|
||||
* the add field menu
|
||||
*
|
||||
* @return DataObjectSet
|
||||
*/
|
||||
function CreatableFields() {
|
||||
$fields = ClassInfo::subclassesFor('EditableFormField');
|
||||
|
||||
if($fields) {
|
||||
array_shift($fields); // get rid of subclass 0
|
||||
$output = new DataObjectSet();
|
||||
foreach($fields as $field => $title) {
|
||||
// get the nice title and strip out field
|
||||
$niceTitle = trim(str_ireplace("Field", "", eval("return $title::\$singular_name;")));
|
||||
|
||||
// keep old javascript happy
|
||||
$title = trim(str_ireplace("Editable", "", $title));
|
||||
|
||||
$output->push(new ArrayData(array(
|
||||
'ClassName' => $title,
|
||||
'Title' => "$niceTitle"
|
||||
)));
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function saveInto(DataObject $record) {
|
||||
|
||||
$name = $this->name;
|
||||
@ -114,12 +144,6 @@ class FieldEditor extends FormField {
|
||||
}
|
||||
}
|
||||
|
||||
/*function addNewField( $newField ) {
|
||||
$newField->ParentID = $this->ID;
|
||||
$newField->write();
|
||||
return $this->renderWith("FieldEditor");
|
||||
}*/
|
||||
|
||||
function addfield() {
|
||||
// get the last field in this form editor
|
||||
$parentID = $this->form->getRecord()->ID;
|
||||
|
@ -1,36 +1,10 @@
|
||||
<div class="FieldEditor <% if isReadonly %>readonly<% end_if %>" id="Fields" name="$Name.Attr">
|
||||
<ul class="TopMenu Menu">
|
||||
<li><% _t('ADD', 'Add') %>:</li>
|
||||
<li>
|
||||
<a href="#" title="<% _t('TEXTTITLE', 'Add text field') %>" id="TextField"><% _t('TEXT', 'Text') %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" title="<% _t('CHECKBOXTITLE', 'Add checkbox') %>" id="Checkbox"><% _t('CHECKBOX', 'Checkbox') %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" title="<% _t('DROPDOWNTITLE', 'Add dropdown') %>" id="Dropdown"><% _t('DROPDOWN', 'Dropdown') %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" title="<% _t('RADIOSETTITLE', 'Add radio button set') %>" id="RadioField"><% _t('RADIOSET', 'Radio') %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" title="<% _t('EMAILTITLE', 'Add email field') %>" id="EmailField"><% _t('EMAIL', 'Email') %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" title="<% _t('FORMHEADINGTITLE', 'Add form heading') %>" id="FormHeading"><% _t('FORMHEADING', 'Heading') %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" title="<% _t('DATETITLE', 'Add date heading') %>" id="DateField"><% _t('DATE', 'Date') %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" title="<% _t('FILETITLE', 'Add file upload field') %>" id="FileField"><% _t('FILE', 'File') %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" title="<% _t('CHECKBOXGROUPTITLE', 'Add checkbox group field') %>" id="CheckboxGroupField"><% _t('CHECKBOXGROUP', 'Checkboxes') %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" title="<% _t('MEMBERTITLE', 'Add member list field') %>" id="MemberListField"><% _t('MEMBER', 'Member List') %></a>
|
||||
</li>
|
||||
|
||||
<% control CreatableFields %>
|
||||
<li><a href="#" title="<% _t('ADD', 'Add') %> $Title" id="$ClassName">$Title</a></li>
|
||||
<% end_control %>
|
||||
</ul>
|
||||
<div class="FieldList" id="Fields_fields">
|
||||
<% control Fields %>
|
||||
@ -43,39 +17,13 @@
|
||||
</div>
|
||||
<ul class="BottomMenu Menu">
|
||||
<li><% _t('ADD', 'Add') %>:</li>
|
||||
<li>
|
||||
<a href="#" title="<% _t('TEXTTITLE', 'Add text field') %>" id="TextField"><% _t('TEXT', 'Text') %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" title="<% _t('CHECKBOXTITLE', 'Add checkbox') %>" id="Checkbox"><% _t('CHECKBOX', 'Checkbox') %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" title="<% _t('DROPDOWNTITLE', 'Add dropdown') %>" id="Dropdown"><% _t('DROPDOWN', 'Dropdown') %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" title="<% _t('RADIOSETTITLE', 'Add radio button set') %>" id="RadioField"><% _t('RADIOSET', 'Radio') %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" title="<% _t('EMAILTITLE', 'Add email field') %>" id="EmailField"><% _t('EMAIL', 'Email') %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" title="<% _t('FORMHEADINGTITLE', 'Add form heading') %>" id="FormHeading"><% _t('FORMHEADING', 'Heading') %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" title="<% _t('DATETITLE', 'Add date heading') %>" id="DateField"><% _t('DATE', 'Date') %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" title="<% _t('FILETITLE', 'Add file upload field') %>" id="FileField"><% _t('FILE', 'File') %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" title="<% _t('CHECKBOXGROUPTITLE', 'Add checkbox group field') %>" id="CheckboxGroupField"><% _t('CHECKBOXGROUP', 'Checkboxes') %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" title="<% _t('MEMBERTITLE', 'Add member list field') %>" id="MemberListField"><% _t('MEMBER', 'Member List') %></a>
|
||||
</li>
|
||||
<% control CreatableFields %>
|
||||
<li><a href="#" title="<% _t('ADD', 'Add') %> $Title" id="$ClassName">$Title</a></li>
|
||||
<% end_control %>
|
||||
</ul>
|
||||
<div class="FormOptions">
|
||||
<% control FormOptions %>
|
||||
$FieldHolder
|
||||
<% end_control %>
|
||||
</div></div>
|
||||
</div>
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user