Fields / Radios

Read More: Fieldmanager_Radios

A set of radio buttons. Often accompanied by a datasource to populate the radio buttons.

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 Radio Buttons

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

    This example will output a list of radio buttons 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_Radios( array(
    		'name' => 'demo-field',
    		'datasource' => new Fieldmanager_Datasource_User,
    	) );
    	$fm->add_meta_box( 'Radio Buttons Demo', array( 'post' ) );
    } );