Skip to content

Commit

Permalink
Merge pull request #23 from symbiote/fix-dependency
Browse files Browse the repository at this point in the history
Fix(dependency) remove hard dependency on SilverStripe\UserForms
  • Loading branch information
stephenmcm authored Nov 15, 2018
2 parents 0b5cb7b + 1d60038 commit 748071e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/editableformfields/EditableDependentDynamicListField.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,17 @@
*
* @author Marcus Nyeholt <marcus@symbiote.com.au>
*/

if (!class_exists(EditableDropdown::class)) {
return;
}

class EditableDependentDynamicListField extends EditableDropdown
{
private static $db = array(
'SourceList' => 'Varchar(512)',
);

private static $table_name = 'EditableDependentDynamicListField';

private static $singular_name = 'Dependent Dynamic List field';
Expand Down Expand Up @@ -71,7 +76,7 @@ public function getCMSFields()
$options = $sourceList->map('Name', 'Title');
}
}

$fields->addFieldToTab('Root.Main', DropdownField::create('SourceList', _t('EditableDependentDynamicListField.SOURCE_LIST_TITLE', 'Source List'), $options));

return $fields;
Expand All @@ -98,7 +103,7 @@ public function getFormField()
$sourceList = DynamicList::get_dynamic_list($source->ListTitle);
if ($sourceList) {
$items = $sourceList->Items();

// now lets create a bunch of option fields
foreach ($items as $sourceItem) {
// now get the dynamic list that is represented by this one
Expand Down
5 changes: 5 additions & 0 deletions src/editableformfields/EditableDynamicListField.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
*
* @author Marcus Nyeholt <marcus@symbiote.com.au>
*/

if (!class_exists(EditableDropdown::class)) {
return;
}

class EditableDynamicListField extends EditableDropdown
{

Expand Down

0 comments on commit 748071e

Please sign in to comment.