function __toString() { $minutes = array(); $minute = 0; while ($minute < 60) { $minutes[] = $minute; $minute += $this->minute_interval; } $hours = array(); foreach (range(0, 23) as $hour) { foreach ($minutes as $minute) { $hours[str_pad($hour, 2, '0', STR_PAD_LEFT) . ':' . str_pad($minute, 2, '0', STR_PAD_LEFT)] = $hour . ':' . str_pad($minute, 2, '0', STR_PAD_LEFT); } } $this->dropdown->setDataSource($hours); $value = $this->dropdown->getValue(); if ($value) { $parts = explode(':', $value); $min_distance = 60; $approx_min = 0; foreach ($minutes as $minute) { if ($min_distance > abs($parts[1] - $minute)) { $min_distance = abs($parts[1] - $minute); $approx_min = $minute; } } if ($min_distance > 60 - $parts[1]) { $approx_min = 0; $parts[0] = str_pad(($parts[0] + 1) % 24, 2, '0', STR_PAD_LEFT); } $this->dropdown->setValue($parts[0] . ':' . str_pad($approx_min, 2, '0', STR_PAD_LEFT)); } return '<div class="form_input_datetime">' . $this->date_picker->__toString() . $this->dropdown->__toString() . '</div>'; }
function __toString() { $load = new Loader(); $html = $load->helper('html'); $this->beforeHTML = $html->javascript('/widgets/custom/coupleddropdown.js'); $this->beforeHTML .= $html->inlineJavascript('var coupled_empty_' . $this->getId() . ' = "' . $this->empty_value . '";'); $this->afterHTML = $html->img('/widgets/custom/ajax-loader.gif', 'Loading...', array('style' => 'display:none')); $this->setClass('coupleddropdown'); if ($this->filter_column && $this->_data_source instanceof TableReader) { $this->_data_source->where($this->filter_column, $this->related->getValue()); } if ($this->empty_value) { $this->add('0', $this->empty_value); } return parent::__toString(); }
function __toString() { $this->setName($this->getName(), $this->getName() . '[]'); return parent::__toString(); }