/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Actor::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'nombres', $this->nombres])->andFilterWhere(['like', 'apellidos', $this->apellidos]); return $dataProvider; }
public function getNombreActor() { $actor = Actor::find()->where(['id' => $this->actorid])->one(); return $actor->getNombreCompleto(); }
use app\models\Pelicula; use app\models\Actor; use yii\helpers\Html; use yii\widgets\ActiveForm; /* @var $this yii\web\View */ /* @var $model app\models\Actorpelicula */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="actorpelicula-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'actorid')->dropDownList(ArrayHelper::map(Actor::find()->all(), 'id', 'nombres'), ['prompt' => 'Seleccionar actor', 'style' => 'width:300px']); ?> <?php echo $form->field($model, 'peliculaid')->dropDownList(ArrayHelper::map(Pelicula::find()->all(), 'id', 'nombre'), ['prompt' => 'Seleccionar pelicula', 'style' => 'width:300px']); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end();