Returns the available choices for a specific field.
Description
See also
Parameters
- $element
-
(awsmug\Torro_Forms\DB_Objects\Elements\Element) (Required) Element to get choices for.
- $field
-
(string) (Optional) Element field for which to get choices. Default empty string (main field).
Default value: ''
Return
(array) Array of choices.
Source
File: src/db-objects/elements/element-types/choice-element-type-trait.php
public function get_choices_for_field( $element, $field = '' ) { if ( empty( $field ) ) { $field = '_main'; } $choices = array(); $element_choices = $element->get_element_choices(); foreach ( $element_choices as $element_choice ) { $current_field = empty( $element_choice->field ) ? '_main' : $element_choice->field; if ( $current_field !== $field ) { continue; } $choices[] = $element_choice->value; } return $choices; }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |