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.
|
* we can fix the height cropping.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$('.cms .field.dropdown').entwine({
|
$('.cms .field.dropdown, .cms .field.checkboxset').entwine({
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
$(this).find("select:not(.no-chzn)").chosen();
|
$(this).find("select:not(.no-chzn)").data('placeholder', ' ').chosen();
|
||||||
$(this).addClass("has-chzn");
|
$(this).addClass("has-chzn");
|
||||||
|
|
||||||
this._super();
|
this._super();
|
||||||
|
@ -1133,12 +1133,16 @@ class Member extends DataObject {
|
|||||||
// Groups relation will get us into logical conflicts because
|
// Groups relation will get us into logical conflicts because
|
||||||
// Members are displayed within group edit form in SecurityAdmin
|
// Members are displayed within group edit form in SecurityAdmin
|
||||||
$fields->removeByName('Groups');
|
$fields->removeByName('Groups');
|
||||||
|
|
||||||
if(Permission::check('EDIT_PERMISSIONS')) {
|
if(Permission::check('EDIT_PERMISSIONS')) {
|
||||||
$groupsField = new TreeMultiselectField('Groups', false, 'Group');
|
$groupsMap = DataList::create('Group')->map('ID', 'Breadcrumbs')->toArray();
|
||||||
$fields->findOrMakeTab('Root.Groups', singleton('Group')->i18n_plural_name());
|
asort($groupsMap);
|
||||||
$fields->addFieldToTab('Root.Groups', $groupsField);
|
$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).
|
// Add permission field (readonly to avoid complicated group assignment logic).
|
||||||
// This should only be available for existing records, as new records start
|
// This should only be available for existing records, as new records start
|
||||||
// with no permissions until they have a group assignment anyway.
|
// with no permissions until they have a group assignment anyway.
|
||||||
|
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