public function fields($field = null, $option = null)
{
$field_data = null;
if (empty($this->fields)) {
// No fields found
$field_data = array();
} elseif (empty($field)) {
// Return all fields
$field_data = (array) $this->fields;
} elseif (!isset($this->fields[$field]) && !isset($this->pod_data['object_fields'][$field])) {
// Field not found
$field_data = array();
} elseif (empty($option)) {
// Return all field data
if (isset($this->fields[$field])) {
$field_data = $this->fields[$field];
} elseif (isset($this->pod_data['object_fields'])) {
$field_data = $this->pod_data['object_fields'][$field];
}
} else {
// Merge options
if (isset($this->fields[$field])) {
$options = array_merge($this->fields[$field], $this->fields[$field]['options']);
} elseif (isset($this->pod_data['object_fields'])) {
$options = array_merge($this->pod_data['object_fields'][$field], $this->pod_data['object_fields'][$field]['options']);
}
// Get a list of available items from a relationship field
if ('data' == $option && in_array(pods_var_raw('type', $options), PodsForm::tableless_field_types())) {
$field_data = PodsForm::field_method('pick', 'get_field_data', $options);
} elseif (isset($options[$option])) {
$field_data = $options[$option];
}
}
/**
* Modify the field data before returning
*
* @since unknown
*
* @param array $field_data The data for the field.
* @param string|null $field The specific field that data is being return for, if set when method is called or null.
* @param string|null $option Value of option param when method was called. Can be used to get a list of available items from a relationship field.
* @param Pods|object $this The current Pods class instance.
*/
return apply_filters('pods_pods_fields', $field_data, $field, $option, $this);
}