Copied!

CheckBoxMenu allows you to create an array of checkboxes in a menu format. The actual checkboxes are hidden and the user only sees the selected menu options

An All button and a Submit button are also supported and can be added at any point in the menu.

The class can be styled with the cbmenu class (similarly to the simple menu class)

CloneableInstantiable
Constants
public PHPFUI\Base::DEBUG_SOURCE = 1
Methods
public PHPFUI\HTML5Element::__clone()
public __construct(string $name)
 
  • param string $name is the name of the fields that will be posted as an array
public PHPFUI\Base::__toString() : string
public PHPFUI\Base::add(?mixed $item) : static
 

Base add function. Adds to the end of the current objects

  • param mixed $item should be convertable to string
public addAll(string $name = 'All') : PHPFUI\MenuItem
 

Add a select All button. It is appended to the previously added checkboxes.

public PHPFUI\Base::addAsFirst(?mixed $item) : static
 

Base addAsFirst function. Adds to the front of the current object

  • param mixed $item should be convertable to string
public PHPFUI\HTML5Element::addAttribute(string $attribute, string $value = '') : static
 

Add an attribute the the object

  • param string $value of the attribute, blank for just a plain attribute
public addCheckBox(string $name, bool $active, string $value, ?int $index = NULL) : PHPFUI\MenuItem
 

Add a new checkbox / MenuItem

  • param string $name to display to the user
  • param bool $active true if you want this checkbox set on initial display
  • param string $value to return when the checkbox is selected
  • param ?int $index optional index for the checkbox, defaults to [] (next), use -1 for no name
  • return \PHPFUI\MenuItem for further modification if needed
public PHPFUI\HTML5Element::addClass(string $class) : static
 

Add a class to an object

  • param string $class name(s) to add
public PHPFUI\Menu::addMenuItem(PHPFUI\MenuItem $item) : static
public PHPFUI\HTML5Element::addPHPClassName() : static
 

Adds the base PHP class name as a class to this object

public PHPFUI\Menu::addSubMenu(PHPFUI\MenuItem $item, PHPFUI\Menu $subMenu) : static
public addSubmit(PHPFUI\Form $form, string $name = 'Submit') : PHPFUI\MenuItem
 

Add a Submit button in the menu style. It is appended to the previously added checkboxes.

  • param string $name of the posted field
public PHPFUI\Menu::count() : int
 

Number of object in this object. Does not count sub objects.

public PHPFUI\HTML5Element::deleteAttribute(string $attribute) : static
 

Deletes the passed attribute

public PHPFUI\HTML5Element::deleteAttributes() : static
 

Deletes all attributes

public PHPFUI\HTML5Element::deleteClass(string $classToDelete) : static
 

Delete a class from the object

public PHPFUI\HTML5Element::disabled() : static
 

Disabled the element

public PHPFUI\Base::done(bool $done = true) : static
 

Form is done rendering

public PHPFUI\Menu::getActive() : bool
public PHPFUI\HTML5Element::getAttribute(string $attribute) : ?string
 

Get an attribute

  • return ?string does not exist if null
public PHPFUI\HTML5Element::getAttributes() : string
 

Returns the attribute strings. Attributes with values are returned as name/value pairs, attributes without values are returned as just the attribute name.

public PHPFUI\HTML5Element::getClass() : string
 

Returns the class attribute ready for insertion into an element.

public PHPFUI\HTML5Element::getClasses() : array
 

Returns all classes for the object

  • return string[]
public static PHPFUI\Base::getDebug(int $flags = 0) : int
 

Gets the current debug setting

public PHPFUI\HTML5Element::getElement() : string
 

Return the type of the element

public PHPFUI\HTML5Element::getId() : string
 

Return the id of the object. Elements will not have an id unless this method is called. The id is returned as a string starting with id followed by a unique number to the page. Id numbers are deterministic and start start with 1. Once assigned an id, an element will always have the same id. It will get a new id if cloned.

public PHPFUI\HTML5Element::getIdAttribute() : string
 

Return the id attribute of the object as a name/value pair. If no id has been requested, and empty string is returned.

public getMenuItemClass() : string
 

Return the class name for the menu items.

public PHPFUI\Menu::getMenuItems() : array
 
  • return array<string,\PHPFUI\MenuItem>
public PHPFUI\Menu::getName() : string
public PHPFUI\Base::getResponse() : string
 

Get the current response

public PHPFUI\HTML5Element::getToolTip(string $label) : PHPFUI\ToolTip|string
 

Get the tool tip as a string

  • return \ToolTip|string return type depends on if the tip was set as a string or ToolTip object.
public PHPFUI\HTML5Element::hasClass(string $class) : bool
 

Return true if the class is present on the object

public PHPFUI\HTML5Element::hasId() : bool
 

Does this object have an id set already?

public PHPFUI\HTML5Element::hasToolTip() : bool
 
  • return bool if there is a tool tip associated with this element
public PHPFUI\Base::isDone() : bool
 

Returns true if the page needs no more processing

public PHPFUI\HTML5Element::newId() : static
 

Assign a new id to this element.

public PHPFUI\Base::prepend(?mixed $item) : static
 

Add an object in front of existing object

public PHPFUI\Menu::setActiveLink(string $link) : bool
 

Set the active MenuItem by link

  • return bool true if an active link was set
public PHPFUI\Menu::setActiveName(string $name) : bool
 

Set the active MenuItem by name

  • return bool true if an active name was set
public PHPFUI\HTML5Element::setAttribute(string $attribute, string $value = '') : static
 

Set the attribute overwriting the prior value

  • param string $value of the attribute, blank for just a plain attribute
public PHPFUI\HTML5Element::setConfirm( $text) : static
 

A simple way to set a confirm on click

  • param string $text confirm text
public static PHPFUI\Base::setDebug(int $level = 0) : void
 

Set the debug level, 1 or higher is on

public PHPFUI\HTML5Element::setElement( $element) : static
 

You can set the element type if you need to morph it for some reason

  • param string $element
public PHPFUI\Menu::setIconAlignment(string $type) : static
 
  • param string $type must one of top, right, bottom, left
public PHPFUI\HTML5Element::setId( $id) : static
 

Set the base id of the object

  • param string $id to set. Will be returned as set. It is up to the caller to prevent duplicate ids.
public setJavaScriptCallback(string $functionName) : static
 

This javascript function will be called with the field name (including [index]), value and active flag when ever the menu is changed.

If the All MenuItem is clicked, then the callback is passed the all text for name and value.

This callback must be set before adding anything to the menu. Previously added items will not have the callback.

Parameters for the function are field name with index in [], value and boolean indicating active. No return value is supported.

public PHPFUI\Base::setRawResponse(string $response, bool $asJSON = true) : static
 

Sets the page response directly and exits the program

  • return never|static
public PHPFUI\Base::setResponse(string $response, string $color = 'lime') : static
 

Set a response in the standard format ('reponse' and 'color' array) exit will be called after returning the encoded response

  • param string $response to return
  • param string $color used for the save button
  • return never|static
public PHPFUI\HTML5Element::setToolTip(PHPFUI\ToolTip|string $tip) : static
 

Set the tool tip. Can either be a ToolTip or a string. If it is a string, it will be converted to a ToolTip

public PHPFUI\Menu::sort() : static
 

Sort the menu by name displayed to the user.

public PHPFUI\HTML5Element::toggleAnimate(PHPFUI\HTML5Element $element, string $animation) : static
 

Will toggle the provided element on click with the provided animation.

public PHPFUI\HTML5Element::toggleClass(PHPFUI\HTML5Element $element, string $class) : static
 

Will toggle the class on the provided element on click.

public PHPFUI\HTML5Element::transferAttributes(PHPFUI\HTML5Element $from) : static
 

Moves attributes into this object from the passed object

public PHPFUI\HTML5Element::transferClasses(PHPFUI\HTML5Element $from) : static
 

Moves classes into this object from the passed object

public PHPFUI\Menu::walk(string $method, ?mixed $argument = NULL) : static
Properties
protected array PHPFUI\Menu::$menuItems = []
 
  • var array<string,\PHPFUI\MenuItem|\PHPFUI\Menu>
protected array PHPFUI\Menu::$menuLabels = []
 
  • var array<string,string>
protected bool PHPFUI\Menu::$sorted = false
Methods
protected PHPFUI\HTML5Element::getBody() : string
protected PHPFUI\HTML5Element::getEnd() : string
protected PHPFUI\Base::getItems() : array
 
  • return array
protected getStart() : string
protected PHPFUI\HTML5Element::upCastCopy(PHPFUI\HTML5Element $to, PHPFUI\HTML5Element $from) : object
 

Clones the first object and fills it with properties from the second object

Properties
private ?PHPFUI\MenuItem $allMenuItem = NULL
private string $callbackName = ''
private string $className
private string $name
private ?PHPFUI\MenuItem $submitMenuItem = NULL
Methods
public static PHPFUI\Base::getDebug(int $flags = 0) : int
 

Gets the current debug setting

public static PHPFUI\Base::setDebug(int $level = 0) : void
 

Set the debug level, 1 or higher is on

© 2025 Bruce Wells
Search Namespaces \ Classes
Configuration