Skip to content

Instantly share code, notes, and snippets.

@traversal
Created October 9, 2014 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save traversal/f32bf2abc414cad855a8 to your computer and use it in GitHub Desktop.
Save traversal/f32bf2abc414cad855a8 to your computer and use it in GitHub Desktop.
Checkbox List Labels
<?php
// Add this method to MPFT_CheckboxList
// this returns an associative array of the selections, with keys being the checkbox values, values being the labels.
function selections() {
if (!isset($this->_tv)) {
$options = $this->field()->info->type_options;
if (isset($options, $options["values"])) {
$this->_tv = WOOF_HTML::option_values($options["values"]);
if (is_array($this->_tv)) {
$this->_vt = array_flip($this->_tv);
} else {
$this->_tv = array();
$this->_vt = array();
}
} else {
$this->_tv = array();
$this->_vt = array();
}
}
$text = array();
$vals = $this->values();
foreach ($vals as $val) {
if (isset($this->_vt[$val])) {
$text[$val] = $this->_vt[$val];
}
}
return $text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment