PHP Class Carbon_Fields\Field\Relationship_Field

Allows selecting and manually sorting entries from any custom post type.
Inheritance: extends Field
Show file Open project: htmlburger/carbon-fields

Protected Properties

Property Type Description
$allow_duplicates
$max
$post_type

Public Methods

Method Description
admin_init ( ) Admin initialization actions
allow_duplicates ( boolean $allow = true ) Specify whether to allow each entry to be selected multiple times.
get_item_label ( integer $id, string $type, string $subtype = '' ) : string Used to get the label of an item.
get_options ( ) : array Generate the item options for the relationship field.
get_title_by_type ( integer $id, string $type, string $subtype = '' ) : string Used to get the title of an item.
item_template ( boolean $display_input = true ) Serves as a Underscore template for the relationship items.
set_max ( integer $max ) Set the maximum allowed number of selected entries.
set_post_type ( string | array $post_type ) Set the post type of the entries.
template ( ) The main Underscore template of this field.
to_json ( boolean $load ) : array Returns an array that holds the field data, suitable for JSON representation.

Method Details

admin_init() public method

Admin initialization actions
public admin_init ( )

allow_duplicates() public method

Specify whether to allow each entry to be selected multiple times.
public allow_duplicates ( boolean $allow = true )
$allow boolean

get_item_label() public method

Can be overriden or extended by the carbon_relationship_item_label filter.
public get_item_label ( integer $id, string $type, string $subtype = '' ) : string
$id integer The database ID of the item.
$type string Item type (post, term, user, comment, or a custom one).
$subtype string Subtype - "page", "post", "category", etc.
return string $label The label of the item.

get_options() public method

Generate the item options for the relationship field.
public get_options ( ) : array
return array $options The selectable options of the relationship field.

get_title_by_type() public method

Can be overriden or extended by the carbon_relationship_title filter.
public get_title_by_type ( integer $id, string $type, string $subtype = '' ) : string
$id integer The database ID of the item.
$type string Item type (post, term, user, comment, or a custom one).
$subtype string The subtype - "page", "post", "category", etc.
return string $title The title of the item.

item_template() public method

Used for both the selected and the selectable options.
public item_template ( boolean $display_input = true )
$display_input boolean Whether to display the selected item input field.

set_max() public method

Set the maximum allowed number of selected entries.
public set_max ( integer $max )
$max integer

set_post_type() public method

Set the post type of the entries.
public set_post_type ( string | array $post_type )
$post_type string | array Post type

template() public method

The main Underscore template of this field.
public template ( )

to_json() public method

This data will be available in the Underscore template and the Backbone Model.
public to_json ( boolean $load ) : array
$load boolean Should the value be loaded from the database or use the value from the current instance.
return array

Property Details

$allow_duplicates protected property

protected $allow_duplicates

$max protected property

protected $max

$post_type protected property

protected $post_type