Return field array from a Pod, a field’s data, or a field option
Function Definition
public function fields ( $field = null, $option = null )
Source File: /pods/classes/Pods.php
Since: 2.0
Parameters
PARAMETER | TYPE | DETAILS |
---|---|---|
$field | (null|string) | The field name. |
$option | (null|string) | The option name. |
Returns
(array|\Pods\Whatsit\Field|mixed|null) The fields, the field, the field option, or null if not found.
Examples
Correct Usage
// Get all fields from a Pod. $fields = $pod->fields(); // Get a certain field from a Pod. $field = $pod->fields( 'field_name' ); // Get a certain field option from a Pod. $field_type = $pod->fields( 'field_name', 'type' ); // Grab the default value of a Pod field. $default = $pod->fields( 'field_name', 'default_value' ); // Get a list of data that you can select from a Relationship field. $related_data = $pod->fields( 'related_field_name', 'data' ); // Traverse and get field options from related object fields. $another_field_label = $pod->fields( 'related_field_name.another_field', 'label' );