2017 © Pedro Peláez
 

library htcklist

Generates a list of checkboxes for multi selection.

image

flsouto/htcklist

Generates a list of checkboxes for multi selection.

  • Monday, March 20, 2017
  • by flsouto
  • Repository
  • 0 Watchers
  • 1 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

HtCklist

This library can be used to generate a multichoice field. I recommend you take a look at the documentation of its parent classes in order to grasp all the inherited functionality:, (*1)

Installation

Via composer:, (*2)

composer require flsouto/htcklist

Usage

In the following example we generate a list which allows a user to pick multiple days of the week., (*3)

<?php
use FlSouto\HtCklist;
require("vendor/autoload.php");

$select = new HtCklist("select_days");
$select->options([1=>'Mon',2=>'Tue',3=>'Wed',4=>'Thu',5=>'Fri',6=>'Sat']);

echo $select;

Outputs:, (*4)










Notice: the options method also accepts other formats besides an associative array. Take a look at the documentation of the HtChoice class in order to learn more., (*5)

Changing the separator

By default, the separator used to separate the options is a <br/> element, that is, a line break. But you can change that by using the separator method. In the example below we change the separator to be two spaces so that the options are displayed horizontally:, (*6)

<?php
use FlSouto\HtCklist;
require("vendor/autoload.php");

$select = new HtCklist("select_days");
$select->options([1=>'Mon',2=>'Tue',3=>'Wed',4=>'Thu',5=>'Fri',6=>'Sat'])
    ->separator("&nbsp;&nbsp;");

echo $select;

Outputs:, (*7)




                 

Selecting options

If you have read the documentation of the HtField and the HtWidget parent classes you already know that you are supposed to use the context method in order to populate the value of a field/widget. In this case, you have to pass an array with the values of the options you want to be checked when the field is displayed:, (*8)

<?php
use FlSouto\HtCklist;
require("vendor/autoload.php");

$select = new HtCklist("select_days");
$select->options([1=>'Mon',2=>'Tue',3=>'Wed',4=>'Thu',5=>'Fri',6=>'Sat']);
$select->context(['select_days'=>[2,5]]); // check Tue and Fri

echo $select;

Outputs:, (*9)










The Versions

20/03 2017

dev-master

9999999-dev

Generates a list of checkboxes for multi selection.

  Sources   Download

The Requires

 

by Fabio Souto

html forms widgets options fields choices multichoice

20/03 2017

1.0.0

1.0.0.0

Generates a list of checkboxes for multi selection.

  Sources   Download

The Requires

 

by Fabio Souto

html forms widgets options fields choices multichoice