Collective\Html\FormBuilder::selectRange PHP Метод

selectRange() публичный Метод

Create a select range field.
public selectRange ( string $name, string $begin, string $end, string $selected = null, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$begin string
$end string
$selected string
$options array
Результат Illuminate\Support\HtmlString
    public function selectRange($name, $begin, $end, $selected = null, $options = [])
    {
        $range = array_combine($range = range($begin, $end), $range);
        return $this->select($name, $range, $selected, $options);
    }

Usage Example

Пример #1
0
 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);
 }
All Usage Examples Of Collective\Html\FormBuilder::selectRange