Well I get the data of a table from my BD and I send them to a select. When I want to save the data of the select to the database I get the error that the field matters has no value
But when checking the data that is sent by post it turns out that if it was sent
Here are my codes
view
<label class="my-1 mr-2" for="inlineFormCustomSelectPref">
Materia
<select class="custom-select " id="inlineFormCustomSelectPref " id="materias" name="materias" >
<option selected >Elige...</option>
@foreach ($materias as $id => $name)
<option value="{{ $name }}">{{$name}}
{!! $errors->first('name', '<span class=error>:message</span>') !!}
</option>
@endforeach
</select>
</label>
controller
public function create()
{
//
$materias = Materia::pluck('nombre','id');
return view('libros.create',compact('materias'));
}
/**
* Store a newly created resource in storage.
*
* @param App\Http\Requests\CreateLibroRequest; $request
* @return \Illuminate\Http\Response
*/
public function store(CreateLibroRequest $request)
{
//
//dd($request->all());
$libro = Libro::create( $request->all() );
//$libro->materias()->attach($request->materias);
return redirect()->route('libros.index');
}