function save($post_id = 0)
 {
     // verify nonce
     if (!isset($_POST['wp_meta_box_nonce']) || !wp_verify_nonce($_POST['wp_meta_box_nonce'], basename(__FILE__))) {
         return $post_id;
     }
     foreach ($this->_meta_box['fields'] as $field) {
         // verify this meta box was shown on the page
         if (!isset($_POST['_cmb_present_' . $field['id']])) {
             continue;
         }
         if (isset($_POST[$field['id']])) {
             $value = (array) $_POST[$field['id']];
         } else {
             $value = array();
         }
         $value = $this->strip_repeatable($value);
         if (!($class = _cmb_field_class_for_type($field['type']))) {
             do_action('cmb_save_' . $field['type'], $field, $value);
         }
         if (!empty($this->_meta_box['repeatable'])) {
             $field['repeatable'] = true;
         }
         $field_obj = new $class($field['id'], $field['name'], $value, $field);
         $field_obj->save($post_id, $value);
     }
     // If we are not on a post, need to refresh the field objects to reflect new values, as we do not get a redirect
     if (!$post_id) {
         $this->fields = array();
         $this->init_fields();
     }
 }
 function save($post_id)
 {
     // verify nonce
     if (!isset($_POST['wp_meta_box_nonce']) || !wp_verify_nonce($_POST['wp_meta_box_nonce'], basename(__FILE__))) {
         return $post_id;
     }
     // check autosave
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     foreach ($this->_meta_box['fields'] as $field) {
         $value = isset($_POST[$field['id']]) ? (array) $_POST[$field['id']] : (array) $_POST[$field['id'] . '[]'];
         if (!($class = _cmb_field_class_for_type($field['type']))) {
             do_action('cmb_save_' . $field['type'], $field, $value);
         }
         if (!empty($this->_meta_box['repeatable'])) {
             $field['repeatable'] = true;
         }
         if (!isset($_POST[$field['id']]) && !isset($_POST[$field['id'] . '[]'])) {
             //TODO: fix this, checkboxes
             continue;
         }
         $field_obj = new $class($field['id'], $field['name'], $value, $field);
         $field_obj->save($post_id);
     }
 }
	public function enqueue_styles() {

		parent::enqueue_styles();

		foreach ( $this->args['fields'] as $f ) {
			$class = _cmb_field_class_for_type( $f['type'] );
			$field = new $class( '', '', array(), $f );
			$field->enqueue_styles();
		}

	}
 public function parse_save_values()
 {
     $values = $this->values;
     $this->values = array();
     $first = reset($values);
     foreach ($first as $key => $field_val) {
         $meta = array();
         foreach ($this->args['fields'] as $construct_field) {
             $name = $this->args['id'] . '[' . $construct_field['id'] . ']';
             // If it's cloneable , make it an array
             if ($this->args['repeatable'] == true) {
                 $name .= '[]';
             }
             // create the fiel object so it can sanitize it's data etc
             $class = _cmb_field_class_for_type($construct_field['type']);
             $field = new $class($name, $construct_field['name'], (array) $values[$construct_field['id']][$key], $construct_field);
             $field->parse_save_values();
             $field->parse_save_value();
             $meta[$construct_field['id']] = $field->get_value();
         }
         if ($this->isNotEmptyArray($meta)) {
             $this->values[] = $meta;
         }
     }
     parent::parse_save_values();
 }