mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
Improved FieldEditor to dynamically get the class for EditableOptions
This commit is contained in:
parent
42932ea47f
commit
0f90ce9596
@ -268,6 +268,9 @@ class FieldEditor extends FormField {
|
|||||||
if($parent) {
|
if($parent) {
|
||||||
$sql_parent = (int)$parent;
|
$sql_parent = (int)$parent;
|
||||||
|
|
||||||
|
$parentObj = EditableFormField::get()->byID($parent);
|
||||||
|
$optionClass = ($parentObj && $parentObj->exists()) ? $parentObj->getRelationClass('Options') : 'EditableOption';
|
||||||
|
|
||||||
$sqlQuery = new SQLQuery();
|
$sqlQuery = new SQLQuery();
|
||||||
$sqlQuery = $sqlQuery
|
$sqlQuery = $sqlQuery
|
||||||
->setSelect("MAX(\"Sort\")")
|
->setSelect("MAX(\"Sort\")")
|
||||||
@ -277,7 +280,7 @@ class FieldEditor extends FormField {
|
|||||||
$sort = $sqlQuery->execute()->value() + 1;
|
$sort = $sqlQuery->execute()->value() + 1;
|
||||||
|
|
||||||
if($parent) {
|
if($parent) {
|
||||||
$object = new EditableOption();
|
$object = Injector::inst()->create($optionClass);
|
||||||
$object->write();
|
$object->write();
|
||||||
$object->ParentID = $parent;
|
$object->ParentID = $parent;
|
||||||
$object->Sort = $sort;
|
$object->Sort = $sort;
|
||||||
|
@ -270,8 +270,8 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
// pass the deleted status onto the element
|
// pass the deleted status onto the element
|
||||||
$(this).parent("li").children("[type=text]").attr("value", "field-node-deleted");
|
$(this).parents("li:first").find("[type=text]:first").attr("value", "field-node-deleted");
|
||||||
$(this).parent("li").hide();
|
$(this).parents("li:first").hide();
|
||||||
|
|
||||||
// Give the user some feedback
|
// Give the user some feedback
|
||||||
statusMessage(userforms.message('REMOVED_OPTION'));
|
statusMessage(userforms.message('REMOVED_OPTION'));
|
||||||
|
Loading…
Reference in New Issue
Block a user