# Association
This field allows to select and reorder multiple post type posts, taxonomy terms, users or comments. Useful for creating links between any of these items.
Field::make( 'association', 'crb_association', __( 'Association' ) )
# Config methods
# set_types( $types )
 It allows you to specify the types of data that you want to have available in this association field.
In this context:
typeis the data type –post,term,user,comment, or a custom value (if implemented).subtypeclarifies the exact type to be used.- For the 
post_typetype, you can usepost,pageor any other registered custom post type. - For the 
taxonomytype, you can usecategory,post_tagor any other registered custom taxonomy. - The 
subtypeis not used for theuserandcommenttypes. 
- For the 
 
Defaults to:
Field::make( 'association', 'crb_association', __( 'Association' ) )
    ->set_types( array(
        array(
            'type'      => 'post',
            'post_type' => 'post',
        )
    ) )
# set_min( $min )
 Allows you to set the minimum number of selected items in an association field. By default, there is no requirement.
Field::make( 'association', 'crb_association' )
    ->set_min( 5 )
# set_max( $max )
 Allows you to limit the maximum number of selected items in an association field. By default, there is no limit.
Field::make( 'association', 'crb_association' )
    ->set_max( 5 )
# set_duplicates_allowed( $allow )
 If enabled will allow the same item to be selected more than once. By default, duplicates are not allowed.
Field::make( 'association', 'crb_association' )
    ->set_duplicates_allowed( true )
# Getting stored values
/* Get the association data as an array */
carbon_get_post_meta( $id, $name );
/*
The above example returns: 
array( 
    0 => array(
        'id' => 20,
        'type' => 'post',
        'subtype' => 'page',
        'value' => 'post:page:20',
    ), 
    1 => array(
        'id' => 16,
        'type' => 'term',
        'subtype' => 'category',
        'value' => 'term:category:16',
    )
)
*/
# Example
The example below registers the following options for the association field:
- Post Type: Page
 - Post Type: Post
 - Taxonomy: Category
 - Taxonomy: Post Tag
 - Users
 - Comments
 
Field::make( 'association', 'crb_association' )
    ->set_types( array(
        array(
            'type' => 'post',
            'post_type' => 'page',
        ),
        array(
            'type' => 'post',
            'post_type' => 'post',
        ),
        array(
            'type' => 'term',
            'taxonomy' => 'category',
        ),
        array(
            'type' => 'term',
            'taxonomy' => 'post_tag',
        ),
        array(
            'type' => 'user',
        ),
        array(
            'type' => 'comment',
        ),
    ) )
# Value Format
array(
    array(
        'value': 'post:page:10',
        'id': 10,
        'type': 'post',
        'subtype': 'page',
    ),
    ...
)