CMB2::update_field_property PHP Method

update_field_property() public method

Update or add a property to a field
Since: 2.0.0
public update_field_property ( string $field_id, string $property, mixed $value, string $parent_field_id = '' ) : mixed
$field_id string Field id
$property string Field property to set/update
$value mixed Value to set the field property
$parent_field_id string (optional) The field id of the group field to remove field from
return mixed Field id. Strict compare to false, as success can return a falsey value (like 0)
    public function update_field_property($field_id, $property, $value, $parent_field_id = '')
    {
        $ids = $this->get_field_ids($field_id, $parent_field_id);
        if (!$ids) {
            return false;
        }
        list($field_id, $sub_field_id) = $ids;
        if (!$sub_field_id) {
            $this->meta_box['fields'][$field_id][$property] = $value;
            return $field_id;
        }
        $this->meta_box['fields'][$field_id]['fields'][$sub_field_id][$property] = $value;
        return $field_id;
    }