2014-07-26 08:05:02 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Firefly\Helper\Form;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class FormHelper
|
|
|
|
*
|
|
|
|
* @package Firefly\Form
|
|
|
|
*/
|
|
|
|
class FormHelper
|
|
|
|
{
|
2014-08-13 07:02:13 +02:00
|
|
|
|
2014-08-10 15:01:46 +02:00
|
|
|
/**
|
|
|
|
* @param null $value
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2014-07-26 08:05:02 +02:00
|
|
|
public function budget($value = null)
|
|
|
|
{
|
|
|
|
|
|
|
|
$str = '<select name="budget_id" class="form-control">';
|
|
|
|
|
|
|
|
$str .= '<option value="0" label="(no budget)"';
|
|
|
|
if (is_null($value) || intval($value) == 0) {
|
|
|
|
$str .= ' selected="selected"';
|
|
|
|
}
|
|
|
|
$str .= '</option>';
|
|
|
|
|
|
|
|
/** @var \Firefly\Storage\Budget\BudgetRepositoryInterface $budgets */
|
|
|
|
$budgets = \App::make('Firefly\Storage\Budget\BudgetRepositoryInterface');
|
|
|
|
$list = $budgets->getAsSelectList();
|
|
|
|
foreach ($list as $id => $name) {
|
|
|
|
$str .= '<option value="' . e($id) . '" label="' . e($name) . '"';
|
|
|
|
if ($id == intval($value)) {
|
|
|
|
$str .= ' selected="selected"';
|
|
|
|
}
|
|
|
|
$str .= '>' . e($name) . '</option>';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$str .= '</select>';
|
|
|
|
|
|
|
|
return $str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|