Skip to content

Commit

Permalink
Pass the field object instance to the group field show_on_cb instead …
Browse files Browse the repository at this point in the history
…of the cmb object instance
  • Loading branch information
jtsternberg committed May 5, 2015
1 parent 4b34020 commit 68bb5bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
* Ability to use non-repeatable group fields by setting the `'repeatable'` field param to `false` when registering a group field type. Props [marcusbattle](https://github.com/marcusbattle), ([#159](https://github.com/WebDevStudios/CMB2/pull/159)).
* Add and enqeueue a front-end specific CSS file which adds additional styles which are typically covered by wp-admin css. ([#311](https://github.com/WebDevStudios/CMB2/issues/311))
* Better handling of the CMB2 javascript (and CSS) required dependencies array. Dependencies are now only added conditionally based on the field types that are actually visible. ([#136](https://github.com/WebDevStudios/CMB2/issues/136))
* **THIS IS A BREAKING CHANGE:** The `group` field type's `'show_on_cb'` property now receives the `CMB2_Field` object instance as an argument instead of the `CMB2` instance. If you're using the `'show_on_cb'` property for a `group` field, please adjust accordingly. _note: you can still retrieve the `CMB2` instance via the `cmb2_get_metabox` helper function._

## 2.0.6 - 2015-04-30

Expand Down
9 changes: 5 additions & 4 deletions includes/CMB2.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,17 @@ public function show_form( $object_id = 0, $object_type = '' ) {
*/
public function render_group( $args ) {

// If field is requesting to be conditionally shown
if ( isset( $args['show_on_cb'] ) && is_callable( $args['show_on_cb'] ) && ! call_user_func( $args['show_on_cb'], $this ) ) {
if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) {
return;
}

if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) {
$field_group = $this->get_field( $args );

// If field is requesting to be conditionally shown
if ( isset( $args['show_on_cb'] ) && is_callable( $args['show_on_cb'] ) && ! call_user_func( $args['show_on_cb'], $field_group ) ) {
return;
}

$field_group = $this->get_field( $args );
$desc = $field_group->args( 'description' );
$label = $field_group->args( 'name' );
$sortable = $field_group->options( 'sortable' ) ? ' sortable' : ' non-sortable';
Expand Down

0 comments on commit 68bb5bf

Please sign in to comment.