本文整理汇总了PHP中cmb2_get_field函数的典型用法代码示例。如果您正苦于以下问题:PHP cmb2_get_field函数的具体用法?PHP cmb2_get_field怎么用?PHP cmb2_get_field使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cmb2_get_field函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($field, \Cmb2Grid\Grid\Cmb2Grid $grid)
{
$this->setParentFieldId($field[0]);
$this->setFieldId($field[1]);
$field = cmb2_get_field($grid->getCmb2Obj(), $this->getParentFieldId());
$this->setField($field);
//parent::__construct( $field, $grid );
/* $this->setGrid( $grid );
if ( is_string( $field ) ) {
$this->setFieldId( $field );
} elseif ( is_array( $field ) ) {
$this->setFieldId( $field[0] );
}
$fieldId = $this->getFieldId();
$field = cmb2_get_field( $grid->getCmb2Obj(), $fieldId );
$this->setField( $field );
if ( is_array( $field ) ) {
if ( isset( $field['class'] ) ) {
$this->setColumnClass( $field['class'] );
}
} */
}
示例2: test_cmb2_get_field
public function test_cmb2_get_field()
{
$val_to_save = '123Abc';
$field_id = 'test_test';
$retrieved = cmb2_get_field($this->cmb_id, $field_id, $this->post_id);
$this->assertInstanceOf('CMB2_Field', $retrieved);
}
示例3: __construct
public function __construct($field, Cmb2Grid $grid)
{
$this->setGrid($grid);
if (is_string($field)) {
$this->setFieldId($field);
} elseif (is_array($field)) {
$this->setFieldId($field[0]);
} elseif (is_a($field, '\\Cmb2Grid\\Grid\\Group\\Cmb2GroupGrid')) {
$this->setFieldId($field->getParentFieldId());
}
$fieldId = $this->getFieldId();
$finalField = cmb2_get_field($grid->getCmb2Obj(), $fieldId);
$this->setField($finalField);
if (is_array($field)) {
if (isset($field['class'])) {
$this->setColumnClass($field['class']);
}
}
}
示例4: cmb2_get_field_value
/**
* Get a field's value.
* @since 1.1.0
* @param array $meta_box Metabox ID or Metabox config array
* @param array $field_id Field ID or all field arguments
* @param int $object_id Object ID
* @param string $object_type Type of object being saved. (e.g., post, user, comment, or options-page).
* Defaults to metabox object type.
* @return mixed Maybe escaped value
*/
function cmb2_get_field_value($meta_box, $field_id, $object_id = 0, $object_type = '')
{
$field = cmb2_get_field($meta_box, $field_id, $object_id, $object_type);
return $field->escaped_value();
}
示例5: test_remove_group_field
public function test_remove_group_field()
{
$cmb = cmb2_get_metabox('test2');
$cmb->remove_field('colorpicker', 'group_field');
$field = cmb2_get_field('test2', 'group_field', $this->post_id);
$mock = array('first_field' => array('name' => 'Field 1', 'id' => 'first_field', 'type' => 'text'));
$this->assertEquals($mock, $field->fields());
}
示例6: test_field_attributes
public function test_field_attributes()
{
$cmb = new CMB2($this->attributes_test);
$field = cmb2_get_field($this->attributes_test['id'], 'attributes_test_field', $this->post_id);
$this->assertInstanceOf('CMB2_Field', $field);
$expected_field = '
<div class="cmb-row cmb-type-text cmb2-id-attributes-test-field table-layout">
<div class="cmb-th"><label for="attributes_test_field">Name</label></div>
<div class="cmb-td">
<input type="number" class="regular-text" name="attributes_test_field" id="arbitrary-id" value="" disabled="disabled" data-test=\'{"one":"One","two":"Two","true":true,"false":false,"array":{"nested_data":true}}\'/>
<p class="cmb2-metabox-description">This is a description</p>
</div>
</div>
';
$this->assertHTMLstringsAreEqual($expected_field, $this->render_field($field));
}
示例7: test_remove_group_field
public function test_remove_group_field()
{
$cmb = cmb2_get_metabox('test2');
$cmb->remove_field('colorpicker', 'group_field');
$field = cmb2_get_field('test2', 'group_field', $this->post_id);
$fields = $field->fields();
$mock_fields = array('first_field' => array('name' => 'Field 1', 'id' => 'first_field', 'type' => 'text'));
foreach ($mock_fields as $field_id => $field_props_array) {
foreach ($field_props_array as $prop_name => $prop_value) {
$this->assertEquals($prop_value, $fields[$field_id][$prop_name]);
}
}
}