PodsField_Pick::input PHP Method

input() public method

Customize output of the form field
Since: 2.0
public input ( string $name, mixed $value = null, array $options = null, array $pod = null, integer $id = null )
$name string
$value mixed
$options array
$pod array
$id integer
    public function input($name, $value = null, $options = null, $pod = null, $id = null)
    {
        global $wpdb;
        $options = (array) $options;
        $form_field_type = PodsForm::$field_type;
        $options['grouped'] = 1;
        $options['table_info'] = array();
        $custom = pods_var_raw(self::$type . '_custom', $options, false);
        $custom = apply_filters('pods_form_ui_field_pick_custom_values', $custom, $name, $value, $options, $pod, $id);
        $ajax = false;
        if (('custom-simple' != pods_var(self::$type . '_object', $options) || empty($custom)) && '' != pods_var(self::$type . '_object', $options, '', null, true)) {
            $ajax = true;
        }
        if (!empty(self::$field_data) && self::$field_data['id'] == $options['id']) {
            $ajax = (bool) self::$field_data['autocomplete'];
        }
        $ajax = apply_filters('pods_form_ui_field_pick_ajax', $ajax, $name, $value, $options, $pod, $id);
        if (0 == pods_var(self::$type . '_ajax', $options, 1)) {
            $ajax = false;
        }
        if ('single' == pods_var(self::$type . '_format_type', $options, 'single')) {
            if ('dropdown' == pods_var(self::$type . '_format_single', $options, 'dropdown')) {
                $field_type = 'select';
            } elseif ('radio' == pods_var(self::$type . '_format_single', $options, 'dropdown')) {
                $field_type = 'radio';
            } elseif ('autocomplete' == pods_var(self::$type . '_format_single', $options, 'dropdown')) {
                $field_type = 'select2';
            } else {
                // Support custom integration
                do_action('pods_form_ui_field_pick_input_' . pods_var(self::$type . '_format_type', $options, 'single') . '_' . pods_var(self::$type . '_format_single', $options, 'dropdown'), $name, $value, $options, $pod, $id);
                do_action('pods_form_ui_field_pick_input', pods_var(self::$type . '_format_type', $options, 'single'), $name, $value, $options, $pod, $id);
                return;
            }
        } elseif ('multi' == pods_var(self::$type . '_format_type', $options, 'single')) {
            if (!empty($value) && !is_array($value)) {
                $value = explode(',', $value);
            }
            if ('checkbox' == pods_var(self::$type . '_format_multi', $options, 'checkbox')) {
                $field_type = 'checkbox';
            } elseif ('multiselect' == pods_var(self::$type . '_format_multi', $options, 'checkbox')) {
                $field_type = 'select';
            } elseif ('autocomplete' == pods_var(self::$type . '_format_multi', $options, 'checkbox')) {
                $field_type = 'select2';
            } else {
                // Support custom integration
                do_action('pods_form_ui_field_pick_input_' . pods_var(self::$type . '_format_type', $options, 'single') . '_' . pods_var(self::$type . '_format_multi', $options, 'checkbox'), $name, $value, $options, $pod, $id);
                do_action('pods_form_ui_field_pick_input', pods_var(self::$type . '_format_type', $options, 'single'), $name, $value, $options, $pod, $id);
                return;
            }
        } else {
            // Support custom integration
            do_action('pods_form_ui_field_pick_input', pods_var(self::$type . '_format_type', $options, 'single'), $name, $value, $options, $pod, $id);
            return;
        }
        pods_view(PODS_DIR . 'ui/fields/' . $field_type . '.php', compact(array_keys(get_defined_vars())));
    }