Пример #1
0
	public function html() {

		$fields = &$this->get_fields();
		$value  = $this->get_value();

		// Reset all field values.
		foreach ( $fields as $field ) {
			$field->set_values( array() );
		}

		// Set values for this field.
		if ( ! empty( $value ) ) {
			foreach ( $value as $field_id => $field_value ) {
				$field_value = ( ! empty( $field_value ) ) ? $field_value : array();
				if ( ! empty( $fields[$field_id] ) ) {
					$fields[$field_id]->set_values( (array) $field_value );
			}
			}
		}

		?>

		<?php if ( $this->args['repeatable'] ) : ?>
			<button class="cmb-delete-field">
				<span class="cmb-delete-field-icon">&times;</span>
				<?php echo esc_html( $this->args['string-delete-field'] ); ?>
			</button>
		<?php endif; ?>

		<?php CMB_Meta_Box::layout_fields( $fields ); ?>

	<?php }
Пример #2
0
    public function html()
    {
        $value = $this->value;
        if (!empty($value)) {
            foreach ($value as $field => $field_value) {
                if (!empty($field) && !empty($this->fields[$field])) {
                    $this->fields[$field]->set_values((array) $field_value);
                } else {
                    if (!empty($this->fields[$field])) {
                        $this->fields[$field]->set_values(array());
                    }
                }
            }
        } else {
            foreach ($this->fields as $field) {
                $field->set_values(array());
            }
        }
        $field = $this->args;
        ?>

		<div class="group <?php 
        echo !empty($field['repeatable']) ? 'cloneable' : '';
        ?>
" style="position: relative">

			<?php 
        if ($this->args['repeatable']) {
            ?>
				<span class="cmb_element">
					<span class="ui-state-default">
						<a class="delete-field ui-icon-circle-close ui-icon">&times;</a>
					</span>
				</span>
			<?php 
        }
        ?>

			<?php 
        CMB_Meta_Box::layout_fields($this->fields);
        ?>

		</div>

	<?php 
    }
    public function html()
    {
        $fields =& $this->get_fields();
        $value = $this->value;
        if (!empty($value)) {
            foreach ($value as $field_id => $field_value) {
                if (!empty($field_value) && !empty($fields[$field_id])) {
                    $fields[$field_id]->set_values((array) $field_value);
                } else {
                    if (!empty($fields[$field_id])) {
                        $fields[$field_id]->set_values(array());
                    }
                }
            }
        } else {
            foreach ($fields as &$field) {
                $field->set_values(array());
            }
        }
        ?>

		<?php 
        if ($this->args['repeatable']) {
            ?>
			<button class="cmb-delete-field" title="Remove field"><span class="cmb-delete-field-icon">&times;</span> Remove Group</button>
		<?php 
        }
        ?>

		<?php 
        CMB_Meta_Box::layout_fields($fields);
        ?>

	<?php 
    }
Пример #4
0
    public function html()
    {
        $field = $this->args;
        $value = $this->value;
        $fields = array();
        foreach ($this->args['fields'] as $f) {
            $field_value = isset($this->value[$f['id']]) ? $this->value[$f['id']] : '';
            $f['uid'] = $field['id'] . '[' . $f['id'] . ']';
            // If it's cloneable , make it an array
            if ($field['repeatable'] == true) {
                $f['uid'] .= '[]';
            }
            $class = _cmb_field_class_for_type($f['type']);
            $f['show_label'] = true;
            // Todo support for repeatble fields in groups
            $fields[] = new $class($f['uid'], $f['name'], array($field_value), $f);
        }
        ?>
		<div class="group <?php 
        echo !empty($field['repeatable']) ? 'cloneable' : '';
        ?>
" style="position: relative">

			<?php 
        if (!empty($this->args['name'])) {
            ?>
			
				<h2 class="group-name"><?php 
            echo $this->args['name'];
            ?>
</h2>
			<?php 
        }
        ?>

			<?php 
        if ($this->args['repeatable']) {
            ?>
				<a class="delete-field button" style="position: absolute; top: -3px; right: -3px">X</a>
			<?php 
        }
        ?>

			<?php 
        CMB_Meta_Box::layout_fields($fields);
        ?>

		</div>

		<?php 
    }
    public function html()
    {
        $field = $this->args;
        $value = $this->value;
        if (!empty($value)) {
            foreach ($value as $field => $field_value) {
                if (!empty($field)) {
                    $this->fields[$field]->set_values((array) $field_value);
                }
            }
        }
        ?>
		<div class="group <?php 
        echo !empty($field['repeatable']) ? 'cloneable' : '';
        ?>
" style="position: relative">

			<?php 
        if ($this->args['repeatable']) {
            ?>
				<a class="delete-field button" style="position: absolute; top: -3px; right: -3px">X</a>
			<?php 
        }
        ?>

			<?php 
        CMB_Meta_Box::layout_fields($this->fields);
        ?>

		</div>

		<?php 
    }