Choice_Element_Type_Trait::get_choices( awsmug\Torro_Forms\DB_Objects\Elements\Element $element )

Returns the available choices.

Description

Parameters

$element

(awsmug\Torro_Forms\DB_Objects\Elements\Element) (Required) Element to get choices for.

Return

(array) Associative array of <code>$field => $choices</code> pairs, with the main element field having the key '_main'.

Source

File: src/db-objects/elements/element-types/choice-element-type-trait.php

	public function get_choices( $element ) {
		$choices = array();

		$element_choices = $element->get_element_choices();
		foreach ( $element_choices as $element_choice ) {
			$field = empty( $element_choice->field ) ? '_main' : $element_choice->field;

			if ( ! isset( $choices[ $field ] ) ) {
				$choices[ $field ] = array();
			}

			$choices[ $field ][] = $element_choice->value;
		}

		return $choices;
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.