CMB2::render_field PHP Method

render_field() public method

Renders a field based on the field type
Since: 2.2.0
public render_field ( array $field_args ) : mixed
$field_args array A field configuration array.
return mixed CMB2_Field object if successful.
    public function render_field($field_args)
    {
        $field_args['context'] = $this->prop('context');
        if ('group' == $field_args['type']) {
            if (!isset($field_args['show_names'])) {
                $field_args['show_names'] = $this->prop('show_names');
            }
            $field = $this->render_group($field_args);
        } elseif ('hidden' == $field_args['type'] && $this->get_field($field_args)->should_show()) {
            // Save rendering for after the metabox
            $field = $this->add_hidden_field($field_args);
        } else {
            $field_args['show_names'] = $this->prop('show_names');
            // Render default fields
            $field = $this->get_field($field_args)->render_field();
        }
        return $field;
    }