mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Using chosen.js for group selection in Member->getCMSFields()
This commit is contained in:
parent
8fa266462f
commit
46628721fe
@ -363,9 +363,9 @@ jQuery.noConflict();
|
||||
* we can fix the height cropping.
|
||||
*/
|
||||
|
||||
$('.cms .field.dropdown').entwine({
|
||||
$('.cms .field.dropdown, .cms .field.checkboxset').entwine({
|
||||
onmatch: function() {
|
||||
$(this).find("select:not(.no-chzn)").chosen();
|
||||
$(this).find("select:not(.no-chzn)").data('placeholder', ' ').chosen();
|
||||
$(this).addClass("has-chzn");
|
||||
|
||||
this._super();
|
||||
|
@ -1135,9 +1135,13 @@ class Member extends DataObject {
|
||||
$fields->removeByName('Groups');
|
||||
|
||||
if(Permission::check('EDIT_PERMISSIONS')) {
|
||||
$groupsField = new TreeMultiselectField('Groups', false, 'Group');
|
||||
$fields->findOrMakeTab('Root.Groups', singleton('Group')->i18n_plural_name());
|
||||
$fields->addFieldToTab('Root.Groups', $groupsField);
|
||||
$groupsMap = DataList::create('Group')->map('ID', 'Breadcrumbs')->toArray();
|
||||
asort($groupsMap);
|
||||
$fields->addFieldToTab('Root.Main',
|
||||
Object::create('CheckboxSetField', 'Groups', singleton('Group')->i18n_plural_name())
|
||||
->setTemplate('CheckboxSetField_Select')
|
||||
->setSource($groupsMap)
|
||||
);
|
||||
|
||||
// Add permission field (readonly to avoid complicated group assignment logic).
|
||||
// This should only be available for existing records, as new records start
|
||||
|
11
templates/forms/CheckboxSetField_Select.ss
Normal file
11
templates/forms/CheckboxSetField_Select.ss
Normal file
@ -0,0 +1,11 @@
|
||||
<%-- Renders a CheckboxField with $multiple=true as a select element which can save into relations.--%>
|
||||
<%-- TODO Make relation saving available on ListboxField --%>
|
||||
<select id="$ID" class="$extraClass" name="$Name[]" multiple="true">
|
||||
<% if Options.Count %>
|
||||
<% control Options %>
|
||||
<option class="$Class" value="$Value"<% if isChecked %> selected="selected"<% end_if %>>
|
||||
$Title
|
||||
</option>
|
||||
<% end_control %>
|
||||
<% end_if %>
|
||||
</select>
|
Loading…
Reference in New Issue
Block a user