Exemple #1
0
 public function edit($id)
 {
     try {
         $row = $this->model->findOrFail($id);
         // Set model vars to row (keep overload attributes)
         $this->set_model_vars_to_row($row);
         // Add translation fields
         if (!empty($this->model->translate)) {
             foreach ($row->translations()->get() as $translation) {
                 foreach ($this->model->translate as $field) {
                     $row[$field . '_' . $translation->language] = $translation->field;
                 }
             }
         }
         foreach ($this->model->form as $field => $type) {
             if ($type == 'multiselect') {
                 $related_model_name = get_related_model_name();
                 $related_model = new $related_model_name();
                 $taglist = $row->field()->get()->lists($related_model->select[0], $related_model->select[1]);
                 if (!empty($taglist)) {
                     $row->field = implode(',', $taglist);
                 }
             }
         }
     } catch (ModelNotFoundexception $e) {
         return App::abort(404);
     }
     return View::make('admin.edit', compact('row'));
 }
Exemple #2
0
     $result .= Form::textarea($id, null, array('id' => $id, 'class' => 'form-control'));
     break;
 case 'boolean':
     $result .= Form::select($id, array(1 => trans('admin.general.boolean.yes'), 0 => trans('admin.general.boolean.no')), null, array('id' => $id, 'class' => 'form-control'));
     break;
 case 'select':
     $related_model_name = get_related_model_name($field, true);
     $related_model = new $related_model_name();
     $select_values = $related_model->orderBy($related_model->select[0])->get()->lists($related_model->select[0], $related_model->select[1]);
     if (!empty($select_values)) {
         $select_values = array('' => '') + $select_values;
     }
     $result .= Form::select($id, $select_values, null, array('id' => $id, 'class' => 'form-control'));
     break;
 case 'multiselect':
     $related_model_name = get_related_model_name($field, flase);
     $related_model = new $related_model_name();
     $taglist = $related_model->all()->lists($related_model->select[0], $related_model->select[0]);
     if (!empty($taglist)) {
         $taglist = implode(',', $taglist);
     } else {
         $taglist = null;
     }
     $result .= Form::text($id, null, array('id' => $id, 'class' => 'form-control multiselect', 'taglist' => $taglist));
     break;
 case 'date':
     $result .= '<div class="input-group">';
     $result .= '<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>';
     $result .= Form::text($id, date('Y-m-d'), array('id' => $id, 'class' => 'form-control datepicker'));
     $result .= '</div>';
     break;