Support the ongoing development of Laravel.io →
Input Database Views

hello i am new to laravel and i am learning as i go i have this problem when i save mi form in the database it go as number i am using a drop down menu mi controller

    public function create()
{
	return View::make('pets.create')
	->with('nerds',Nerd::lists('name'));
}


public function store()
{
	// validate
	$rules = array(
		'name'       => 'required',
		'type'      => 'required',
		'awener' =>     'required'
	);
	$validator = Validator::make(Input::all(), $rules);

	// process the login
	if ($validator->fails()) {
		return Redirect::to('pets/create')
			->withErrors($validator)
			->withInput(Input::except('password'));
	} else {
		// store
		$pet = new Pet;
		$pet->name      = Input::get('name');
		$pet->type      = Input::get('type');
		$pet->awener    = Input::get('awener');

		$pet->save();

		// redirect
		Session::flash('message', 'Successfully created a pet!');
		return Redirect::to('pets');
	}
}

mi view

	<div class="form-group">
	{{ Form::label('awener', 'awener') }}
	{{ Form::select('awener',$nerds,Input::old('awener'), array('class' => 'form-control')) }}
</div>
Last updated 3 years ago.
0

Try $pet = new Pet();

Last updated 10 years ago.
0

dint work i am trying to get the NAME of mi client from the table NERDS and put it in the AWENER in mi PET table when i check the DB i see numbers when it should be a text

0

Sign in to participate in this thread!

Eventy

Your banner here too?

neoarcan neoarcan Joined 21 Jun 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.