| 1 |
<?php
|
| 2 |
|
| 3 |
function betterselect_elements() {
|
| 4 |
$type = array();
|
| 5 |
$type['select'] = array('#process' => array('betterselect_process' => array()));
|
| 6 |
return $type;
|
| 7 |
}
|
| 8 |
|
| 9 |
function betterselect_process($element) {
|
| 10 |
if ($element['#multiple']) {
|
| 11 |
$element['#type'] = 'checkboxes';
|
| 12 |
if ($element['#options'][0] == t('<none>')) {
|
| 13 |
unset($element['#options'][0]);
|
| 14 |
}
|
| 15 |
if(count($element['#options']) > 10) {
|
| 16 |
$fixheight = ' betterfixed';
|
| 17 |
|
| 18 |
}
|
| 19 |
unset($element['#theme']);
|
| 20 |
$element = expand_checkboxes($element);
|
| 21 |
$element['#prefix'] = "<div class=\"betterselect{$fixheight}\">". $element['#prefix'];
|
| 22 |
$element['#suffix'] .= '</div>';
|
| 23 |
static $path;
|
| 24 |
if (!isset($path)) {
|
| 25 |
$path = drupal_get_path('module', 'betterselect');
|
| 26 |
drupal_add_css($path .'/betterselect.css');
|
| 27 |
drupal_add_js($path .'/betterselect.js');
|
| 28 |
}
|
| 29 |
}
|
| 30 |
return $element;
|
| 31 |
}
|