2017 © Pedro Peláez
 

cakephp-plugin multiselect

Toggle, select or multiselect a database field based on a set of conditions

image

gintonicweb/multiselect

Toggle, select or multiselect a database field based on a set of conditions

  • Tuesday, February 23, 2016
  • by gintonicweb
  • Repository
  • 2 Watchers
  • 2 Stars
  • 106 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Multiselect

Build Status Coverage Total Downloads License, (*1)

Toggle, select or multiselect a database field based on a set of conditions, (*2)

Install

Using Composer:, (*3)

composer require muffin/multiselect:1.0.x-dev

You then need to load the plugin. You can use the shell command:, (*4)

bin/cake plugin load Muffin/Multiselect

or by manually adding statement shown below to your app's config/bootstrap.php:, (*5)

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., (*6)

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:, (*7)

$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., (*8)

$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 select
  • state Either mark the active field as true or false
  • scope Selections can be grouped by fields defined here
  • limit Maximum number of selected elements
  • order Order 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., (*9)

Bugs & Feedback

http://github.com/usemuffin/multiselect/issues, (*10)

License

Copyright (c) 2015, Use Muffin and licensed under The MIT License., (*11)

The Versions

23/02 2016

dev-master

9999999-dev https://github.com/usemuffin/multiselect

Toggle, select or multiselect a database field based on a set of conditions

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp multiselect muffin

27/11 2015

0.0.1

0.0.1.0 http://gintoniccms.com

Multiselect behavior plugin for CakePHP

  Sources   Download

MIT

The Requires

 

The Development Requires

16/11 2015

0.0.0

0.0.0.0 http://gintoniccms.com

Multiselect behavior plugin for CakePHP

  Sources   Download

MIT

The Requires

 

The Development Requires