Hello,
I have this form :
{{ Form::open(['route' => 'abbonementen.store']) }}
{{ Form::select('abbonement-soort', ['Jaarabbonement - groot', 'Jaarabbonement -middel', 'Jaarabbonement - klein ', 'knipkaart']) }};
</div>
<div class="form-group">
{{ Form::label('bedrag', 'Bedrag') }}
{{ Form::input('decimal', 'bedrag') }}
</div>
{{Form::submit('abbonementen opslaan')}}
{{Form::close()}}
and this migration :
public function up()
{
Schema::create('abbonementen', function($table)
{
$table->increments('id');
$table->string('abbonementen-soort');
$table->integer('bedrag');
});
}
and this is my save in the controller :
public function store()
{
$abonnementen = New Abbonement;
$abonnementen->soort = Input::get('abbonement-soort');
$abonnementen->bedrag = Input::get('bedrag');
$abonnementen->save();
}
but as soon as I press the submit button I see a string to array conversion.
Roelof
try this:
{{ Form::select('abbonement-soort', array_merge(array('0' => 'Select abbonement-soort' , 'Jaarabbonement - groot' => 'Jaarabbonement - groot' , 'Jaarabbonement -middel' => 'Jaarabbonement -middel', 'Jaarabbonement - klein' => 'Jaarabbonement - klein', 'knipkaart' => 'knipkaart')),Input::old('abbonement-soort')) }}
Thanks it do not solve the problem. I still see the error message.
When I do this :
return Input:all();
it gives this output:
{"_token":"xxxxxx","abbonement-soort":"Jaarabbonement - klein","bedrag":"4"}
it seems to me that somewhere down this line there must be a error ;
$abonnementen->soort = Input::get('abbonement-soort');
$abonnementen->bedrag = Input::get('bedrag');
Roelof
Have you try:
$input = Input:all();
$abonnementen->soort = $input['abbonement-soort']; $abonnementen->bedrag = $input['bedrag'];
Solved that one. The error was in the model where abbonementen was a array.
But now I see a message that the table abbonementen is not found. But when I look with phpadmin it is there :(
And like this?
$abonnementen = New Abbonement(); $abonnementen->soort = Input::get('abbonement-soort'); $abonnementen->bedrag = Input::get('bedrag'); $abonnementen->save();
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community