Fields / Checkboxes

Read More: Fieldmanager_Checkboxes

A set of multiple checkboxes which stores as an array of the checked values.

This class extends Fieldmanager_Options, which allows you to define options (values) via an array or via a dynamic Datasource, like posts, terms, or users.

  1. Example 1: Basic List of Checkboxes

    add_action( 'fm_post_post', function() {
    	$fm = new Fieldmanager_Checkboxes( array(
    		'name' => 'demo-field',
    		'options' => array(
    			'red' => 'Red',
    			'green' => 'Green',
    			'blue' => 'Blue',
    		),
    	) );
    	$fm->add_meta_box( 'Checkboxes Demo', array( 'post' ) );
    } );
  2. Example 2: Datasource Example

    This example will output a list of checkboxes with all users on the site. To provide the field with that data, it uses the User Datasource.

    add_action( 'fm_post_post', function() {
    	$fm = new Fieldmanager_Checkboxes( array(
    		'name' => 'demo-field',
    		'datasource' => new Fieldmanager_Datasource_User,
    	) );
    	$fm->add_meta_box( 'Checkboxes Demo', array( 'post' ) );
    } );