I need to select multiple parent / child categories in a front end form, I am using a TreeMultiSelectField to achieve this in SilverStripe 3.5.1 and can successfully populate this dropdown in the CMS Page, but when I add to my front end form the field doesn't render and I get the following errors in the browser console:
Uncaught TypeError: Cannot read property 'msie' of undefined
at jquery.entwine-dist.js?m=1482356614:757
at jquery.entwine-dist.js?m=1482356614:801
(anonymous) @ jquery.entwine-dist.js?m=1482356614:757
(anonymous) @ jquery.entwine-dist.js?m=1482356614:801
TreeDropdownField.js?m=1482356614:2 Uncaught TypeError: $.entwine is not a function
at TreeDropdownField.js?m=1482356614:2
at TreeDropdownField.js?m=1482356614:446
This is my form
<?php
class CreateArtifactPage extends ListPage {
private static $db = array ( );
private static $has_one = array(
'LotteryFeed' => 'LotteryFeed',
'ProofImage' => 'Image'
);
private static $many_many = array(
'Images' => 'Image'
);
private static $belongs_many_many = array(
'BelongSections' => 'CatalogueSection'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
$internalURLField = TreeMultiSelectField::create('BelongSectionsID', 'Select Section', 'CatalogueSection'); // this works!!!!
$fields->addFieldsToTab('Root.Main', array($internalURLField));
return $fields;
}
}
class CreateArtifactPage_Controller extends ListPage_Controller {
private static $allowed_actions = array( 'NewArtifactForm' );
public function NewArtifactForm() {
$map = LotteryFeed::get()->map('ID','Title');
// Create fields
$fields = FieldList::create(
TextField::create('Title', 'Name'),
TextField::create('URLSegment'),
TextField::create('Content', 'Description'),
TreeMultiSelectField::create('BelongSectionsID', 'Select Section', 'CatalogueSection'), // returns $.entwine errrors in the console as above
OptionsetField::create('LotteryFeedID', 'LotteryFeed', $map, LotteryFeed::get()->first()->ID),
TextField::create('Brand', 'Item Brand'),
TextField::create('Year', 'Year Purchased'),
TextField::create('Location', 'Item Location'),
TextField::create('Price', 'Item Price'),
FileAttachmentField::create('ProofImage', 'Proof of ownership')
->setThumbnailHeight(80)
->setThumbnailWidth(80)
->setMaxResolution(50000000),
FileAttachmentField::create('Images', 'Artifact Images')
->setThumbnailHeight(80)
->setThumbnailWidth(80)
->setMaxResolution(50000000),
CheckboxField::create('IsFeatured', 'Add item to Feature list?'),
CheckboxField::create('EnableComments', 'Allow users to ask questions?')
);
// Create actions
$actions = new FieldList(
FormAction::create('submit', 'Create New Item')
);
$required = new RequiredFields('Title', 'URLSegment', 'Content', 'Price');
$form = new Form($this, 'NewArtifactForm', $fields, $actions, $required);
return $form;
}
// Write data into DataObject
public function submit($data, $form) {
$submission = new Artifact();
$form->saveInto($submission);
$submission->write();
return $this->redirectBack();
}
}
Can anyone help to resolve this issue?