Carbon_Fields\Field\Relationship_Field::to_json PHP Method

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
    public function to_json($load)
    {
        $field_data = parent::to_json($load);
        if (!empty($field_data['value'])) {
            $value = array();
            $field_data['value'] = maybe_unserialize($field_data['value']);
            foreach ($field_data['value'] as $single_value) {
                $post_type = get_post_type($single_value);
                $value[] = array('id' => $single_value, 'title' => $this->get_title_by_type($single_value, 'post', $post_type), 'type' => 'post', 'subtype' => $post_type, 'label' => $this->get_item_label($single_value, 'post', $post_type), 'is_trashed' => get_post_status($single_value) == 'trash');
            }
            $field_data['value'] = $value;
        }
        $field_data = array_merge($field_data, array('options' => $this->get_options(), 'max' => $this->max, 'allow_duplicates' => $this->allow_duplicates));
        return $field_data;
    }