gintonicweb/multiselect
最新稳定版本:0.0.1
Composer 安装命令:
composer require gintonicweb/multiselect
包简介
Toggle, select or multiselect a database field based on a set of conditions
README 文档
README
Toggle, select or multiselect a database field based on a set of conditions
Install
Using Composer:
composer require muffin/multiselect:1.0.x-dev
You then need to load the plugin. You can use the shell command:
bin/cake plugin load Muffin/Multiselect
or by manually adding statement shown below to your app's config/bootstrap.php:
Plugin::load('Muffin/Multiselect');
Usage
In a playlist, a single song can be play at the time. Whenever a song is marked
as playing, all of the other songs are marked as not playing. for this we use the
boolean field playing.
CREATE table songs(
id int(10) unsigned NOT NULL auto_increment,
title varchar(255) NOT NULL,
playing tinyint(1) NOT NULL,
);
Load the behavior in your model SongsTable.php:
$this->addBehavior('Multiselect.Multiselect', ['playing']);
More complex use cases can be covered like the following. Where only 2 articles can
be marked as featured at the time for the same author. When a third article is marked
as featured, one of the 3 articles gets unfeatured. In this case, ordered by the
least view count and by modification date.
$this->addBehavior('Multiselect.Multiselect', [
'featured' => [
'state' => true,
'scope' => ['author_id'],
'limit' => 2,
'order' => [
'view_count' => 'ASC',
'modified' => 'ASC',
],
],
]);
Configuration
[field_name]The name of the field used as selectstateEither mark the active field astrueorfalsescopeSelections can be grouped by fields defined herelimitMaximum number of selected elementsorderOrder in which to unselect fields when the limit is exceeded
Patches & Features
- Fork
- Mod, fix
- Test - this is important, so it's not unintentionally broken
- Commit - do not mess with license, todo, version, etc. (if you do change any, bump them into commits of their own that I can ignore when I pull)
- Pull request - bonus point for topic branches
To ensure your PRs are considered for upstream, you MUST follow the CakePHP coding standards.
Bugs & Feedback
http://github.com/usemuffin/multiselect/issues
License
Copyright (c) 2015, Use Muffin and licensed under The MIT License.
统计信息
- 总下载量: 115
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-09-01