function crumbs_Admin_ElementObject_WeightsExpansible::value_callback in Crumbs, the Breadcrumbs suite 7.2
Callback for $element['#value_callback']
Parameters
array $element:
array|bool $input:
array $form_state:
Return value
array
Overrides crumbs_Admin_ElementObject_Abstract::value_callback
File
- lib/
Admin/ ElementObject/ WeightsExpansible.php, line 13
Class
Code
function value_callback(&$element, $input = FALSE, $form_state = array()) {
if ($input === FALSE) {
return isset($element['#default_value']) ? $element['#default_value'] : array();
}
else {
$weights = array();
// Make sure that all weights are distinct and positive.
asort($input);
$i = 0;
foreach ($input as $key => $weight) {
if (is_numeric($weight)) {
$weights[$key] = ++$i;
}
elseif ('disabled' === $weight) {
$weights[$key] = FALSE;
}
}
return $weights;
}
}