/**
 * @param array                    $params
 * @param Smarty_Internal_Template $smarty
 *
 * @throws SmartyException
 * @return string
 *
 * @author Kovács Vince
 */
function smarty_function_form_select($params, Smarty_Internal_Template &$smarty)
{
    if (!isset($params['_name'])) {
        throw new SmartyException('Missing _name attribute for form_select tag');
    }
    $name = $params['_name'];
    $list = isset($params['_list']) ? $params['_list'] : array();
    if (isset($params['_default'])) {
        $list = array('' => $params['_default']) + $list;
    }
    $selected = isset($params['_selected']) ? $params['_selected'] : (isset($params['_populate']) && $params['_populate'] ? \Input::get($name) : null);
    $range = isset($params['_range']) && $params['_range'];
    unset($params['_name']);
    unset($params['_list']);
    unset($params['_selected']);
    unset($params['_range']);
    unset($params['_populate']);
    if ($range) {
        if (!isset($params['_begin'])) {
            throw new SmartyException('Missing _begin attribute for form_select tag');
        }
        if (!isset($params['_end'])) {
            throw new SmartyException('Missing _end attribute for form_select tag');
        }
        $begin = $params['_begin'];
        $end = $params['_end'];
        unset($params['_begin']);
        unset($params['_end']);
        return Form::selectRange($name, $begin, $end, $selected, $params);
    }
    return Form::select($name, $list, $selected, $params);
}
Example #2
0
function buildActive()
{
    $html = '';
    $html .= '<label for="active">' . trans('admin.active') . '</label>';
    $html .= Form::select('active', selectBoolean(), null, ['class' => 'form-control select2-simple', 'style' => 'width: 100%;']);
    return $html;
}
Example #3
0
 /** @inheritdoc */
 public static function displayForm($value, &$settings, $model)
 {
     // No point in ever showing this field if lang isn't enabled
     if (!\CMF::$lang_enabled) {
         return '';
     }
     \Lang::load('languages', true, 'en', true, true);
     $settings = static::settings($settings);
     $include_label = isset($settings['label']) ? $settings['label'] : true;
     $required = isset($settings['required']) ? $settings['required'] : false;
     $errors = $model->getErrorsForField($settings['mapping']['fieldName']);
     $has_errors = count($errors) > 0;
     $input_attributes = isset($settings['input_attributes']) ? $settings['input_attributes'] : array('class' => 'input-xxlarge');
     if ($settings['active_only']) {
         $options = array_map(function ($lang) {
             return \Arr::get(\Lang::$lines, 'en.languages.' . $lang['code'], \Lang::get('admin.errors.language.name_not_found'));
         }, \CMF\Model\Language::select('item.code', 'item', 'item.code')->orderBy('item.pos', 'ASC')->where('item.visible = true')->getQuery()->getArrayResult());
     } else {
         $options = \Arr::get(\Lang::$lines, 'en.languages', array());
     }
     // Whether to allow an empty option
     if (isset($settings['mapping']['nullable']) && $settings['mapping']['nullable'] && !$required && $settings['allow_empty']) {
         $options = array('' => '') + $options;
     }
     $label = !$include_label ? '' : \Form::label($settings['title'] . ($required ? ' *' : '') . ($has_errors ? ' - ' . $errors[0] : ''), $settings['mapping']['fieldName'], array('class' => 'item-label'));
     $input = \Form::select($settings['mapping']['fieldName'], $value, $options, $input_attributes);
     if (isset($settings['wrap']) && $settings['wrap'] === false) {
         return $label . $input;
     }
     return html_tag('div', array('class' => 'controls control-group' . ($has_errors ? ' error' : '')), $label . $input);
 }
 public static function select($name, $label, $attribs = array(), $modelPair = NULL, $wrapper = 1)
 {
     if (isset($attribs['valueArray'])) {
         $selectValueArray = $attribs['valueArray'];
         unset($attribs['valueArray']);
     }
     if (isset($attribs['range'])) {
         for ($i = $attribs['range'][0]; $i <= $attribs['range'][1]; $i++) {
             $selectValueArray[$i] = $i;
         }
         unset($attribs['range']);
     }
     $value = isset($attribs['value']) ? (string) $attribs['value'] : null;
     if (is_array($modelPair)) {
         $modelName = $modelPair[0];
         $selectValueColumn = $modelPair[1];
         $selectNameColumn = $modelPair[2];
         $model = $modelName::orderBy($selectNameColumn)->get();
         foreach ($model as $item) {
             $selectValueArray[$item->{$selectValueColumn}] = $item->{$selectNameColumn};
         }
     }
     $selectOutput = Form::select($name, $selectValueArray, $value, $attribs) . self::_getInputError($name);
     if ($wrapper == 1) {
         return '<li id="' . $name . '_label">' . Form::label($name, $label) . '<div id="' . $name . '_input" class="input_field">' . $selectOutput . '</div></li>';
     } else {
         return $selectOutput;
     }
 }
 protected function select($data, $show)
 {
     $select = [];
     foreach ($data as $d) {
         if (is_array($show)) {
             $value = '';
             foreach ($show as $show_key) {
                 $value .= Str::title($show_key) . ': ' . $d[$show_key];
                 if (end($show) != $show_key) {
                     $value .= ' | ';
                 }
             }
         } elseif (is_callable($show)) {
             $value = $show($d);
         } else {
             $value = $d[$show];
         }
         $select[$d['id']] = $value;
     }
     if (Request::has($this->name)) {
         $this->id = Request::get($this->name);
     } else {
         if (isset($this->value->id)) {
             $this->id = $this->value->id;
         } else {
             $this->id = $this->value;
         }
     }
     echo \Form::select($this->name, ['0' => Request::ajax() ? '(current)' : '(none)'] + $select, $this->id, $this->attributes);
 }
Example #6
0
 public function build()
 {
     $output = "";
     if (!isset($this->style)) {
         $this->style = "margin:0 2px 0 0; vertical-align: middle";
     }
     unset($this->attributes['id']);
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = $this->description;
             }
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             $this->attributes['multiple'] = 'multiple';
             $output .= \Form::select($this->name . '[]', $this->options, $this->values, $this->attributes);
             $output .= $this->extra_output;
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
Example #7
0
 function build()
 {
     $output = "";
     if (!isset($this->style) and !isset($this->attributes['style'])) {
         $this->style = "width:290px;";
     }
     unset($this->attributes['type'], $this->attributes['size']);
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = $this->description;
             }
             $output = "<div class='help-block'>" . $output . "</div>";
             break;
         case "create":
         case "modify":
             $output = \Form::select($this->name, $this->options, $this->value, $this->attributes) . $this->extra_output;
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
function recurse_pages($pages, $spaces = 0, $layoutsBlocks = [], $pageWidgets = [], $pagesWidgets = [])
{
    $data = '';
    foreach ($pages as $page) {
        // Блок
        $currentBlock = array_get($pageWidgets, $page['id'] . '.0');
        $currentPosition = array_get($pageWidgets, $page['id'] . '.1');
        $data .= '<tr data-id="' . $page['id'] . '" data-parent-id="' . $page['parent_id'] . '">';
        $data .= '<td>';
        if (!empty($page['childs'])) {
            $data .= '<div class="input-group">';
        }
        $data .= Form::select('blocks[' . $page['id'] . '][block]', [], $currentBlock, ['class' => 'widget-blocks form-control', 'data-layout' => $page['layout_file'], 'data-value' => $currentBlock]);
        if (!empty($page['childs'])) {
            $data .= "<div class=\"input-group-btn\">" . Form::button(NULL, ['data-icon' => 'level-down', 'class' => 'set_to_inner_pages btn btn-warning', 'title' => trans('widgets::core.button.select_childs')]) . '</div></div>';
        }
        $data .= '</td><td>';
        $data .= Form::text('blocks[' . $page['id'] . '][position]', (int) $currentPosition, ['maxlength' => 4, 'size' => 4, 'class' => 'form-control text-right widget-position']);
        $data .= '</td><td></td>';
        if (acl_check('page::edit')) {
            $data .= '<th>' . str_repeat("-&nbsp;", $spaces) . link_to_route('backend.page.edit', $page['title'], [$page['id']]) . '</th>';
        } else {
            $data .= '<th>' . str_repeat("-&nbsp;", $spaces) . $page['title'] . '</th>';
        }
        $data .= '</tr>';
        if (!empty($page['childs'])) {
            $data .= recurse_pages($page['childs'], $spaces + 5, $layoutsBlocks, $pageWidgets, $pagesWidgets);
        }
    }
    return $data;
}
Example #9
0
 /**
  * [blockZones description]
  * @param  [type] $page_id  [description]
  * @param  [type] $block_id [description]
  * @param  [type] $zone     [description]
  * @param  string $name     [description]
  * @param  string $id       [description]
  * @return [type]           [description]
  */
 public function blockZones($page_id, $block_id, $zone, $name = 'change-zone', $id = 'change-zone')
 {
     if ($block_id) {
         $layout = $this->page->find($page_id)->layout;
         $zones = \Theme::zones($layout);
         return \Form::select($name, $zones, $zone, array('id' => $id, 'data-page' => $page_id, 'class' => 'form-control'));
     }
 }
Example #10
0
 public function input($name, array $attr = NULL)
 {
     if (is_array($this->choices)) {
         return Form::select($name, $this->choices, $this->value, $attr);
     } else {
         return Form::input($name, $this->verbose(), $attr);
     }
 }
 /**
  * Form Component
  */
 public static function formComponent()
 {
     $_templates = Themes::getTemplates();
     foreach ($_templates as $template) {
         $templates[basename($template, '.template.php')] = basename($template, '.template.php');
     }
     echo '<div class="col-xs-3">' . Form::open() . Form::hidden('csrf', Security::token()) . Form::label('sandbox_form_template', __('Sandbox template', 'sandbox')) . Form::select('sandbox_form_template', $templates, Option::get('sandbox_template'), array('class' => 'form-control')) . Html::br() . Form::submit('sandbox_component_save', __('Save', 'sandbox'), array('class' => 'btn btn-default')) . Form::close() . '</div>';
 }
Example #12
0
 public function input($name, $value, array $attr = NULL)
 {
     $model = Sprig::factory($this->model);
     $choices = $model->select_list($model->pk());
     if ($this->empty) {
         Arr::unshift($choices, '', '-- ' . __('None'));
     }
     return Form::select($name, $choices, $this->verbose($value), $attr);
 }
Example #13
0
 public function option($data, $name, $options, $default = NULL, $attrs = array())
 {
     if (!$this->view->preview) {
         return;
     }
     $default_attrs = array('style' => 'display:none', 'property' => $name, 'property-type' => 'option');
     $attrs = Arr::merge($default_attrs, $attrs);
     return Form::select($name, $options, $this->get($data, $name, $default), $attrs);
 }
Example #14
0
function selectGroup($name, $options, $value = NULL, $errors, $attributes = [])
{
    $errorClass = $errors->first($name) ? "has-error" : "";
    $output = "<div class='form-group {$errorClass}'>";
    $output .= Form::label($name, ucwords($name));
    $output .= Form::select($name . "[]", $options, $value, $attributes);
    $output .= $errors->first($name, '<label>:message</label>');
    return "{$output}</div>";
}
Example #15
0
/**
 * @param $targetLanguage
 * @return string
 *
 */
function addTargetLanguageSelect($targetLanguage)
{
    $selectedValue = isset($targetLanguage->value) && isset($targetLanguage->value->text) && ($targetLanguage->value->text == 'fr' || $targetLanguage->value->text == 'en') ? $targetLanguage->value->text : 'fr';
    $p = "<p>";
    $p .= "<label>" . $targetLanguage->label . "</label>";
    $p .= Form::select('extend[' . $targetLanguage->key . ']', array('fr' => 'Français', 'en' => 'Anglais'), $selectedValue, array('class' => ''));
    $p .= "</p>";
    return $p;
}
Example #16
0
 public static function li_select($fieldname, $text, array $options, $value = NULL, array $attributes = array(), $error = "")
 {
    $atts = array_merge($attributes, array('id'=>$fieldname));
    echo "<li class=\"input_field input_select\">";
    echo Form::label($fieldname, $text);
    echo Form::select($fieldname, $options, $value, $atts);
    echo "<span class=\"error\">$error</span>";
    echo "</li>";
 }
Example #17
0
 public function render_input()
 {
     $params = $this->params();
     if (!isset($params['options'])) {
         throw new Exception('The Select field needs an array of possible
             values=>names under the "options" key in the field params!');
     }
     //echo Kohana::debug( $this->_params    ); die();
     return Form::select($this->name(), $params['options'], $this->value(), array_diff_key($this->params(), array('options' => 1)));
 }
Example #18
0
 public function input($name, array $attr = NULL)
 {
     // TODO: cache?
     $relatedItems = Bamboo::get_list($this->model);
     $options = array();
     foreach ($relatedItems as $relatedItem) {
         $options[$relatedItem->{$relatedItem->__id_field}->raw()] = $relatedItem->{$relatedItem->__name_field}->raw();
     }
     return Form::select($name, $options, $this->value, $attr);
 }
Example #19
0
 public function input($name, $value, array $attr = NULL)
 {
     // Make the value verbose
     $value = $this->verbose($value);
     if (is_array($this->choices)) {
         return Form::select($name, $this->choices, $value, $attr);
     } else {
         return Form::input($name, $value, $attr);
     }
 }
Example #20
0
 /** inheritdoc */
 public static function displayForm($value, &$settings, $model)
 {
     $id = isset($value) ? $value->id : '';
     $settings = static::settings($settings);
     $settings['cid'] = 'field_' . md5($settings['mapping']['fieldName'] . static::type());
     $required = isset($settings['required']) ? $settings['required'] : false;
     $include_label = isset($settings['label']) ? $settings['label'] : true;
     $target_class = $settings['mapping']['targetEntity'];
     $target_table = \CMF\Admin::getTableForClass($target_class);
     $target_prop = $settings['mapping']['isOwningSide'] === true ? $settings['mapping']['inversedBy'] : $settings['mapping']['mappedBy'];
     if (empty($target_prop) || is_null($model->id)) {
         $target_prop = false;
     }
     $add_link = \Uri::create('/admin/' . $target_table . '/create?_mode=inline&_cid=' . $settings['cid'] . ($target_prop !== false ? '&' . $target_prop . '=' . $model->id : ''));
     $options = $target_class::options(\Arr::get($settings, 'filters', array()), array(), null, null, null, is_array($settings['select2']), \Arr::get($settings, 'group_by'));
     $has_controls = $settings['create'] !== false;
     // Description?
     $description = isset($settings['description']) ? '<span class="help-block">' . $settings['description'] . '</span>' : '';
     if ($settings['allow_empty']) {
         $options = array('' => '') + $options;
     }
     $errors = $model->getErrorsForField($settings['mapping']['fieldName']);
     $has_errors = count($errors) > 0;
     $input_attributes = $settings['input_attributes'];
     $label = !$include_label ? '' : \Form::label($settings['title'] . ($required ? ' *' : '') . ($has_errors ? ' - ' . $errors[0] : ''), $settings['mapping']['fieldName'], array('class' => 'item-label'));
     $add_link = html_tag('a', array('href' => $add_link, 'class' => 'btn btn-mini btn-create'), '<i class="fa fa-plus"></i> &nbsp;create ' . strtolower($target_class::singular()));
     // Permissions
     $settings['can_edit'] = \CMF\Auth::can('edit', $target_class);
     $settings['can_create'] = \CMF\Auth::can('create', $target_class) && $settings['can_edit'];
     $settings['create'] = $settings['create'] && $settings['can_create'];
     $settings['edit'] = $settings['edit'] && $settings['can_edit'];
     if ($settings['create'] === false) {
         $add_link = " ";
     }
     $controls_top = html_tag('div', array('class' => 'controls-top'), $add_link);
     if (is_array($settings['select2'])) {
         $input_attributes['class'] .= 'input-xxlarge select2';
         $input = \Form::select($settings['mapping']['fieldName'], $id, $options, $input_attributes);
         $settings['select2']['placeholder'] = 'click to select ' . strtolower($target_class::singular()) . '...';
         $settings['select2']['target_table'] = $target_table;
         // Permissions
         $settings['select2']['create'] = $settings['create'];
         $settings['select2']['edit'] = $settings['edit'];
         if (!$required) {
             $settings['select2']['allowClear'] = true;
         }
         return array('content' => html_tag('div', array('class' => 'controls control-group' . ($has_controls ? ' field-with-controls' : '') . ($has_errors ? ' error' : ''), 'id' => $settings['cid']), $label . $description . $input . $controls_top) . '<div class="clear"><!-- --></div>', 'widget' => false, 'assets' => array('css' => array('/admin/assets/select2/select2.css'), 'js' => array('/admin/assets/select2/select2.min.js', '/admin/assets/js/fields/select2.js')), 'js_data' => $settings['select2']);
     }
     $input_attributes['class'] .= ' input-xxlarge';
     $input = \Form::select($settings['mapping']['fieldName'], $id, $options, $input_attributes);
     if (isset($settings['wrap']) && $settings['wrap'] === false) {
         return $label . $input;
     }
     return html_tag('div', array('class' => 'controls control-group' . ($has_controls ? ' field-with-controls' : '') . ($has_errors ? ' error' : ''), 'id' => $settings['cid']), $label . $description . $input . $controls_top) . '<div class="clear"><!-- --></div>';
 }
Example #21
0
 public function render()
 {
     $attributes = $this->get_attributes();
     if (isset($attributes['class'])) {
         $attributes['class'] .= ' form-control';
     } else {
         $attributes['class'] = 'form-control';
     }
     $attributes['data-rel'] = 'chosen';
     return Form::select($this->get_name(), $this->get_options(), (string) $this->get_value(), $attributes);
 }
Example #22
0
function rolesDropDown($field_name, $selection = null, $attributes = [])
{
    $options = [];
    $roles = DB::table('roles')->get();
    if (count($roles) > 0) {
        foreach ($roles as $role) {
            $options[$role->id] = $role->name;
        }
    }
    return Form::select($field_name, $options, $selection, $attributes);
}
Example #23
0
 public function generar_lista_con_agrupador_distritos($valor = null)
 {
     \Form::macro('selectOpt', function (\ArrayAccess $collection, $name, $groupBy, $labelBy = 'name', $valueBy = 'id', $value = null, $attributes = array()) {
         $select_optgroup_arr = [];
         foreach ($collection as $item) {
             $select_optgroup_arr[$item->{$groupBy}][$item->{$valueBy}] = $item->{$labelBy};
         }
         return \Form::select($name, $select_optgroup_arr, $value, $attributes);
     });
     return \Form::selectOpt($this->model->orderBy('codigoSemplades')->get(), 'id_circuito', 'distrito', 'codigoSemplades', 'id_circuito', $valor, array('class' => 'form-control', 'data-required' => 'true', 'id' => 'id_circuito'));
 }
Example #24
0
 public function generar_lista_con_servicio_seleccion($valor)
 {
     \Form::macro('selectOpt', function (\ArrayAccess $collection, $name, $groupBy, $labelBy = 'name', $valueBy = 'id', $value = null, $attributes = array()) {
         $select_optgroup_arr = [];
         foreach ($collection as $item) {
             $select_optgroup_arr[$item->{$groupBy}][$item->{$valueBy}] = $item->{$labelBy};
         }
         return \Form::select($name, $select_optgroup_arr, $value, $attributes);
     });
     return \Form::selectOpt($this->model->all(), 'id_caso', 'servicio', 'denominacion', 'id_caso', $valor, array('class' => 'form-control', 'data-required' => 'true', 'id' => 'id_caso'));
 }
Example #25
0
 public function generar_lista_con_agrupador_permisos($valor = null, $id_rol)
 {
     \Form::macro('selectOpt', function (\ArrayAccess $collection, $name, $groupBy, $labelBy = 'name', $valueBy = 'id', $value = null, $attributes = array()) {
         $select_optgroup_arr = [];
         foreach ($collection as $item) {
             $select_optgroup_arr[$item->{$groupBy}][$item->{$valueBy}] = $item->{$labelBy};
         }
         return \Form::select($name, $select_optgroup_arr, $value, $attributes);
     });
     $modulos_asignados = configRolModulo::where('id_rol', $id_rol)->select('id_modulo')->get()->toArray();
     return \Form::selectOpt($this->model->whereNotIn('id_modulo', $modulos_asignados)->orderBy('descripcion')->get(), 'id_modulo', 'agrupador', 'descripcion', 'id_modulo', $valor, array('class' => 'form-control', 'data-required' => 'true', 'id' => 'id_modulo'));
 }
Example #26
0
function page()
{
    global $db, $session;
    //lets get a user
    $user = $db->from('users')->where('id', 1);
    $formOptions = array('action' => $_SERVER['PHP_SELF'], 'id' => 'testForm', 'data' => $user, 'files' => true, 'class' => 'form-horizontal', 'sidebar' => true, 'title' => '', 'description' => '');
    $form = new Form($formOptions, $session);
    $sidebar = array('class' => 'warning', 'title' => 'Be careful!', 'body' => 'Be sure you complete all fields');
    $form->setSidebar($sidebar);
    $emailValidation = array('required' => 'true', 'error' => 'Please supply a valid email address');
    $email = array('field' => 'email', 'label' => "Email", 'description' => '', 'validation' => $emailValidation);
    $form->email($email);
    $firstNameValidation = array();
    $firstName = array('field' => 'firstname', 'label' => "First Name", 'description' => '', 'validation' => $firstNameValidation);
    $form->text($firstName);
    $lastName = array('field' => 'lastname', 'label' => "Last Name", 'description' => 'Fill in your last name');
    $form->text($lastName);
    $taName = array('field' => 'descriptionField', 'label' => "Last Name", 'description' => 'Fill in your last name');
    $form->textarea($taName);
    $phoneOptions = array('field' => 'phone', 'label' => "Phone", 'description' => 'Home Phone');
    $form->phone($phoneOptions);
    $checkOptions = array('field' => 'checkTest', 'label' => "Check here", 'description' => 'You authorize everything');
    $form->checkbox($checkOptions);
    $passwordValidation = array('pattern' => '(?=^.{6,}$)((?=.*\\d)|(?=.*\\W+))(?![.\\n])(?=.*[A-Z])(?=.*[a-z]).*$');
    $passwordOptions = array('field' => 'password', 'label' => "Password", 'description' => 'Enter a password at least 6 characters, with at least one symbol and number.', 'validation' => $passwordValidation);
    $form->password($passwordOptions);
    /*
        $dateValidation = array('disabledDays'=>'0,1','disabledDates'=>array("11/23/2015", "12/25/2015"), 'minDate'=>'11/1/2015', 'maxDate'=>'1/30/2016');
        $secondDateValidation = array('disabledDays'=>'0,1','disabledDates'=>array("11/23/2015", "12/25/2015"), 'minDate'=>'11/1/2015', 'maxDate'=>'1/30/2016');
        $dateOptions = array('field'=>'startdate', 'label'=>'Start/Stop Dates', 'description' =>'Enter a start  and stop date', 'validation' => $dateValidation,
            'second_field'=>'enddate',  'second_validation' => $secondDateValidation );
        $form->date($dateOptions);
    
        $timeValidation = array('stepping'=>5,'disabledDays'=>'0,1','disabledDates'=>array("11/23/2015", "12/25/2015"), 'minDate'=>'11/1/2015', 'maxDate'=>'1/30/2016');
        $secondTimeValidation = array('disabledDays'=>'0,1','disabledDates'=>array("11/23/2015", "12/25/2015"), 'minDate'=>'11/1/2015', 'maxDate'=>'1/30/2016');
        $dateOptions = array('field'=>'starttime', 'label'=>'Start/Stop Times', 'description' =>'Enter a start  and stop time', 'validation' => $timeValidation,
            'second_field'=>'endtime',  'second_validation' => $secondTimeValidation );
        $form->time($dateOptions);
    */
    $timeValidation = array('stepping' => 5, 'disabledDays' => '0,1', 'disabledDates' => array("11/23/2015", "12/25/2015"), 'minDate' => '11/1/2015', 'maxDate' => '1/30/2016');
    $secondTimeValidation = array('stepping' => 5, 'disabledDays' => '0,1', 'disabledDates' => array("11/23/2015", "12/25/2015"), 'minDate' => '11/1/2015', 'maxDate' => '1/30/2016');
    $dateOptions = array('field' => 'startdatetime', 'label' => 'Start/Stop Date Times', 'description' => 'Enter a start  and stop date time', 'validation' => $timeValidation, 'second_field' => 'enddatetime', 'second_validation' => $secondTimeValidation);
    $form->datetime($dateOptions);
    $options = array('field' => 'department', 'options' => array(0 => 'Advertising', 1 => "Circulation", 2 => 'Production'), 'label' => 'Department', 'description' => 'Select your department');
    $form->select($options);
    $options = array('field' => 'publications', 'url' => '/ajax/forms/publications.php', 'label' => 'Publication', 'description' => 'Select a publication');
    $form->remoteSelect($options);
    $form->generate();
    //var_dump($this->formScripts);
    //grab any form scripts and append them to the global scripts array
    $GLOBALS['scripts'] = array_merge($GLOBALS['scripts'], $form->formScripts);
}
Example #27
0
 /**
  * Render
  * 
  * Renders a filter for
  * a column
  * 
  * @access	public
  * @param	Spark\Grid_Column_Filter	Filter
  * @return	Spark\Grid_Column_Filter_Interface
  */
 public function render(\Grid_Column_Filter $filter)
 {
     // Get options
     $options = $filter->get_column()->get_options();
     // Html fallback
     $html = '';
     // Make sure we have an array of options
     if ($options->get_data()) {
         $html = \Form::select($filter->get_column()->get_identifier(), $filter->get_user_value(), array(null => 'Select') + $options->get_data(), array('class' => 'filter', 'style' => 'width: 100px;'));
     }
     $filter->set_html(html_tag('div', null, $html));
     return $this;
 }
Example #28
0
 public function buildControl($type, $name, $value = null, $attibutes = array(), $options = array())
 {
     switch ($type) {
         case 'select':
             return \Form::select($name, $options, $value, $attributes);
         case 'password':
             return \Form::password($name);
         case 'checkbox':
             return \Form::checkbox($name);
         default:
             return \Form::input($type, $name, $value);
     }
 }
 public function postLoadSupplierProducts()
 {
     if (Request::ajax()) {
         $post = Input::all();
         $supplier = Supplier::find($post['suppliersId']);
         if (!is_null($supplier)) {
             $products = $supplier->products()->orderBy('name')->get();
             return View::make('products.select')->with('products', $products)->render();
         } else {
             return Form::select('product', array('' => ' - Seleccione - '), null, array('class' => 'form-control', 'id' => 'product'));
         }
     }
 }
Example #30
0
 /**
  * Input for create item
  * @return string Form::input
  */
 public function input_create($value)
 {
     $id = $value->id;
     $field = isset($this->item['field']) ? $this->item['field'] : 'name';
     $values_model = $value->clear()->find_all()->as_array($field);
     $values = array();
     foreach ($values_model as $value) {
         $values[$value->id] = $value->{$field};
     }
     if (!$this->item['notnull']) {
         Arr::unshift($values, 0, '');
     }
     return Form::select($this->item['name'], $values, $id);
 }