The best way to do this is using Form Model Binding (http://four.laravel.com/docs/html#form-model-binding):
Use an existing model or create an 'empty' model class:
class NoTable extends Eloquent {
protected $guarded = array();
}
Find your model or instantiate your empty class and fill it with data:
public function getSampleform() {
// Load database data here
$model = new NoTable;
$model->fill(['name' => 'antonio', 'amount' => 10]);
return View::make('sampleform')->with(compact('model'));
}
If you'll use your form with a table that you already have data on it, this is how you uset it:
public function getSampleform() {
// Locate the model and store it in a variable:
$model = User::find(1);
// Then you just pass it to your view:
return View::make('sampleform')->with(compact('model'));
}
To have your form populated, use Form Model Binding, this is an example in Blade:
{{ Form::model($model, array('route' => array('sample.form')) ) }}
{{ Form::text('name') }}
{{ Form::text('amount') }}
{{ Form::close() }}
You don't even have to pass your Input data, because Laravel will populate your inputs using what comes first:
1 - Session Flash Data (Old Input)
2 - Explicitly Passed Value (wich may be null or not)
3 - Model Attribute Data
And Laravel will also take care of csrf token for you, using Form::open() or Form::model().