Create a select range field.
public function selectRangeWithInterval(string $name, int $start, int $end, int $interval, int $value = null, array $options = []) : string { if ($interval == 0) { return parent::selectRange($name, $start, $end, $value, $options); } $items = []; $items[$value] = $value; $startValue = $start; $endValue = $end; $interval *= $interval < 0 ? -1 : 1; if ($start > $end) { $interval *= $interval > 0 ? -1 : 1; $startValue = $end; $endValue = $start; } for ($i = $startValue; $i < $endValue; $i += $interval) { $items[$i . ""] = $i; } $items[$endValue] = $endValue; return $this->select($name, $items, $value, $options); }
/** * Create a select range field. * * @param string $name * @param string $begin * @param string $end * @param string $selected * @param array $options * @return string * @static */ public static function selectRange($name, $begin, $end, $selected = null, $options = array()) { return \Collective\Html\FormBuilder::selectRange($name, $begin, $end, $selected, $options); }
/** * Create a select range field. * * @param string $name * @param string $begin * @param string $end * @param string $selected * @param array $options * * @return string */ public function selectRange($name, $begin, $end, $selected = null, $options = []) { $this->addErrorClass($name, $options); $tags['input'] = parent::selectRange($name, $begin, $end, $selected, $options); $tags['error'] = $this->getErrorTag($name); return $this->buildTags($tags); }