Example #1
0
 public function test_cmb2_row_classes_string()
 {
     // Test with string
     $args = $this->field_args;
     // Add row classes statically as a string
     $args['row_classes'] = 'these are some classes';
     $field = new CMB2_Field(array('object_id' => $this->object_id, 'object_type' => $this->object_type, 'group' => $this->group, 'field_args' => $args));
     $classes = $field->row_classes();
     $this->assertEquals('cmb-type-text cmb2-id-test-test table-layout these are some classes', $classes);
 }
Example #2
0
/**
 * Manually render a field column display.
 *
 * @param  array      $field_args Array of field arguments.
 * @param  CMB2_Field $field      The field object
 */
function yourprefix_display_text_small_column($field_args, $field)
{
    ?>
	<div class="custom-column-display <?php 
    echo $field->row_classes();
    ?>
">
		<p><?php 
    echo $field->escaped_value();
    ?>
</p>
		<p class="description"><?php 
    echo $field->args('description');
    ?>
</p>
	</div>
	<?php 
}
Example #3
0
/**
 * Manually render amount field.
 *
 * @since  1.7
 *
 * @param  array      $field_args Array of field arguments.
 * @param  CMB2_Field $field      The field object
 *
 * @return void
 */
function give_cmb_amount_field_render_row_cb($field_args, $field)
{
    // Get args.
    $id = $field->args('id');
    $label = $field->args('name');
    $name = $field->args('_name');
    $description = $field->args('description');
    $attributes = $field->args('attributes');
    $attributes_string = '';
    $row_class = $field->row_classes();
    // Get attributes.
    if (!empty($attributes)) {
        foreach ($attributes as $attribute_name => $attribute_val) {
            $attributes_string[] = "{$attribute_name}=\"{$attribute_val}\"";
        }
        $attributes_string = implode(' ', $attributes_string);
    }
    // Get row class.
    if (!empty($row_class) && is_array($row_class)) {
        $row_class = implode(' ', $row_class);
    }
    ?>
	<div class="cmb-row <?php 
    echo $row_class;
    ?>
">
		<div class="cmb-th">
			<label for="<?php 
    echo $id;
    ?>
"><?php 
    echo $label;
    ?>
</label>
		</div>
		<div class="cmb-td">
			<?php 
    echo give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '';
    ?>
			<input id="<?php 
    echo $id;
    ?>
" type="text" name="<?php 
    echo $name;
    ?>
" <?php 
    echo $attributes_string;
    ?>
/>
			<?php 
    echo give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '';
    ?>

			<span class="cmb2-metabox-description"><?php 
    echo $description;
    ?>
</span>
		</div>
	</div>
	<?php 
}