PUM_Fields::select_templ_callback( $args )


Description Description


Source Source

File: includes/class-pum-fields.php

	public function select_templ_callback( $args ) {
        if ( $args['select2'] ) {
            $args['class'] .= '  pum-field-select2';
		}

        $multiple = null;
        if ( $args['multiple'] ) {
            $multiple = 'multiple';
            $args['class'] .= '  pum-field-select--multiple';
            $args['name'] .= $args['as_array'] ? '[]' : '';
       }

		$this->field_before( $args );

		$this->field_label( $args ); ?>

	    <select id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" data-placeholder="<?php echo esc_attr( $args['placeholder'] ); ?>" data-allow-clear="true" <?php echo $multiple; ?>>

		<?php if ( ! empty( $args['options'] ) ) {
			foreach ( $args['options'] as $label => $option ) { ?>
				<option value="<?php echo esc_attr( $option ); ?>" {{pumSelected(data.<?php echo esc_attr( $args['templ_name'] ); ?>, '<?php echo $option; ?>', true)}}>
					<?php echo esc_html( $label ); ?>
				</option><?php
			}
		} ?>

		</select><?php

		$this->field_description( $args );

		$this->field_after();
	}

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.