Tribe__Field::dropdown()
generate a dropdown field
Return
(string) the field
Source
File: src/Tribe/Field.php
public function dropdown() {
$field = $this->do_field_start();
$field .= $this->do_field_label();
$field .= $this->do_field_div_start();
if ( is_array( $this->options ) && ! empty( $this->options ) ) {
$field .= '<select';
$field .= $this->do_field_name();
$field .= " id='{$this->id}-select'";
$field .= " class='tribe-dropdown'";
$field .= '>';
foreach ( $this->options as $option_id => $title ) {
$field .= '<option value="' . esc_attr( $option_id ) . '"';
if ( is_array( $this->value ) ) {
$field .= isset( $this->value[0] ) ? selected( $this->value[0], $option_id, false ) : '';
} else {
$field .= selected( $this->value, $option_id, false );
}
$field .= '>' . esc_html( $title ) . '</option>';
}
$field .= '</select>';
$field .= $this->do_screen_reader_label();
} elseif ( $this->if_empty ) {
$field .= '<span class="empty-field">' . (string) $this->if_empty . '</span>';
} else {
$field .= '<span class="tribe-error">' . esc_html__( 'No select options specified', 'tribe-common' ) . '</span>';
}
$field .= $this->do_field_div_end();
$field .= $this->do_field_end();
return $field;
}