Probleme mit einem Problem in Laravel 4, in einem "Kontakt" -Modell Bearbeitungsformular, kann ich alle Felder aktuelle Werte mit Ausnahme derjenigen aus dem Multiple-Select, die eine Beziehung mit einem anderen Modell "Firma ". Es ist eine Viele-zu-Viele-Beziehung. Ich bekomme die Liste der Firmen, aber keine werden ausgewählt, auch wenn eine Beziehung besteht.Mehrfachauswahl Bearbeitungsformular ausgewählte Werte
Hier ist meine bearbeiten Form:
{{ Form::model($contact, array('route' => array('crm.contacts.update', $contact->id), 'id' => 'edit-contact')) }}
<div class="control-group">
{{ Form::label('first_name', 'First Name', array('class' => 'control-label')) }}
{{ Form::text('first_name') }}
</div>
<div class="control-group">
{{ Form::label('last_name', 'Last Name', array('class' => 'control-label')) }}
{{ Form::text('last_name') }}
</div>
<div class="control-group">
{{ Form::label('email', 'Company Email', array('class' => 'control-label')) }}
{{ Form::text('email') }}
</div>
<div class="control-group">
{{ Form::label('company_ids', 'Company', array('class' => 'control-label')) }}
{{ Form::select('company_ids[]', $companies, array('',''), array('multiple'), Input::old('company_ids[]')) }}
</div>
{{ Form::close() }}
Mein Controller:
public function edit($id)
{
$contact = Contact::find($id);
$company_options = Company::lists('name', 'id');
return View::make('crm.contacts.edit')
->with('contact', $contact)
->with('companies', $company_options);;
}
Alle Ideen, wie die Mehrfachauswahlfeld mit vorhandenen Werten vorausgefüllt haben?
Dank
Wo ist der beste Platz zum Einfügen? start.php? Danke, – maunoxyd
sicher, ich benutze eine Datei FormMacros.php und ich schließe es in der app/start/global.php – Ryun
Array (1,2) soll die ausgewählten Elemente sein, nicht wahr? Ich habe es versucht, aber es funktioniert nicht. Bitte, mehr Erklärung benötigt. Danke. @Ryun –