0

データベース内の既存のエントリを編集するためのフォームを作成中です。これを行うために Form::model アプローチを使用していますが、うまくいかないようです。フィールドは空のままです。

ServerController.php

/**
* Editing servers
*/
public function edit($name)
{
  $server = Server::find($name);
  $keywords = ($server->getKeywords()) ? $server->getKeywords() : array();
  $countries = $this->getCountries();
  return View::make('server/edit', array('server' => $server, 'countries' => $countries));
}

public function update($name) 
{
  $server = Server::find($name);
  // Did it succeed?
  if($server->save()) {
    Session::flash('success', 'You server was edited!');
    return Redirect::route('server.view', array($name));
  }

  // Did not validate
  if(Input::get('keywords')) {
    $keywords = Input::get('keywords');
    Session::flash('keywords', $keywords);
  }
  Session::flash('danger', "<b>Oops! There were some problems processing your update</b><br/>" . implode("<br/>", $server->errors()->all()));
  return Redirect::route('server.edit', array($name))->withInput()->withErrors($server->errors());
}

フォーム

{{ Form::model($server, array('route' => array('server.update', $server->name), 'class' => 'form-horizontal', 'role' => 'form', 'files' => true)) }}
  <div class="form-group {{ $errors->has('email') ? 'has-error' : '' }}">
    {{ Form::label('email', 'Email', array('class' => 'control-label col-md-4')) }}
    <div class="col-md-4">
      {{ Form::text('email', '', array('class' => 'form-control')) }}
      {{ $errors->first('email', '<br/><div class="alert alert-danger">:message</div>') }}
    </div>
  </div>
  (some more fields)
{{ Form::close() }}
4

1 に答える 1