php - Adding a select for foreign key object serverfireteam/panel -
i'm using serverfireteam laravelpanel (which uses zofe/rapyd-laravel ). created crud controller entity. entity has foreign key table. want show autocomplete foreign key shows empty selectbox.
my controller code this:
public function edit($entity){ parent::edit($entity); $this->edit = \dataedit::source(new \app\regal()); $this->edit->add('bezeichnung', 'bezeichnung','text'); $this->edit->add('nummer', 'nummer','text'); $this->edit->add('maxpaletten', 'max paletten je ebene','text'); $this->edit->add('anzahlebenen', 'anzahl ebenen','text'); $this->edit->add('kunde_id','kunde','select')->options(\app\kunde::lists("name", "id")); return \view::make('regale.editpanel', array( 'title' => $this->entity , 'edit' => $this->edit )); }
and model files:
class kunde extends model { protected $table = 'kunden'; public function listpaletten(){ return $this->hasmany('app\models\palette'); } public function listadressen(){ return $this->hasmany('app\models\adresse'); } public function listregale(){ return $this->hasmany('app\models\regal'); } public function listartikel(){ return $this->hasmany('app\models\artikel'); } }
..
class regal extends model { protected $table = 'regale'; public function kunde(){ return $this->belongsto('app\models\kunde'); } }
you using options method, options method used selectbox .
as explained in document :
autocomplete (input field autocomplete feature using twitter typeahead , ajax features using relation.fieldname , search() method )
$this->edit->add('author.fullname', 'author', 'autocomplete')->search(array('firstname', 'lastname'));
Comments
Post a Comment