PUM_Fields::objectselect_templ_callback( $args )


Description Description


Source Source

File: includes/class-pum-fields.php

	public function objectselect_templ_callback( $args ) {
		if ( $args['type'] != 'objectselect' ) {
			$args['class'] .= '  pum-field-objectselect';
		}

		$args['class'] .= '  pum-field-select  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 ); ?>

		<# var templ_name = '<?php echo esc_attr( $args['templ_name'] ); ?>'; #>

		<# if (typeof data[templ_name] === 'undefined') {
			data[templ_name] = '';
		} #>

	    <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; ?> data-objecttype="<?php echo esc_attr( $args['object_type'] ); ?>" data-objectkey="<?php echo esc_attr( $args['object_key'] ); ?>">
			<?php if ( ! empty( $args['options'] ) ) {
				foreach ( $args['options'] as $label => $option ) { ?>
					<option value="<?php echo esc_attr( $option ); ?>" {{pumSelected(data[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.