/** * Finds the Mother model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Mother the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Mother::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
use yii\helpers\ArrayHelper; use app\models\Mother; use app\models\Tarea; /* @var $this yii\web\View */ /* @var $model app\models\personas */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="personas-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'id_mother')->dropDownList(ArrayHelper::map(Mother::find()->all(), 'id', 'nombre'))->label('Mother'); ?> <?php echo $form->field($model, 'nombre')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'orden')->textInput(); ?> <?php echo $form->field($model, 'relPersonaTareas[]')->checkboxList(ArrayHelper::map(Tarea::find()->all(), 'id', 'nombre'))->label('Tareas'); ?> <div class="form-group">
/** * @return \yii\db\ActiveQuery */ public function getIdMother() { return $this->hasOne(Mother::className(), ['id' => 'id_mother']); }
public function actionIndex() { $model = Mother::find()->all(); return $this->render('index', ['model' => $model]); }