コード例 #1
0
ファイル: ParentsSearch.php プロジェクト: adem-team/advanced
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Parents::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(['parent_id' => $this->parent_id]);
     $query->andFilterWhere(['like', 'parent', $this->parent]);
     return $dataProvider;
 }
コード例 #2
0
ファイル: _form.php プロジェクト: adem-team/advanced
use lukisongroup\front\models\Parents;
use lukisongroup\front\models\Child;
$data = ["red" => "red", "green" => "green", "blue" => "blue", "orange" => "orange", "white" => "white", "black" => "black", "purple" => "purple", "cyan" => "cyan", "teal" => "teal"];
/* @var $this yii\web\View */
/* @var $model lukisongroup\child\models\Child */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="child-form">

    <?php 
$form = ActiveForm::begin();
?>

   <?php 
echo $form->field($model, 'PARENT_ID')->widget(Select2::classname(), ['data' => ArrayHelper::map(Parents::find()->all(), 'parent_id', 'parent'), 'language' => 'en']);
?>

    <?php 
echo $form->field($model, 'CHILD_NAME')->textInput(['maxlength' => true]);
?>

    <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();
?>
コード例 #3
0
ファイル: _form.php プロジェクト: adem-team/advanced
use kartik\select2\select2;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $model lukisongroup\grandchild\models\Grandchild */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="grandchild-form">

    <?php 
$form = ActiveForm::begin();
?>

    
     <?php 
echo $form->field($model, 'CHILD_ID')->dropDownList(ArrayHelper::map(Parents::find()->asArray()->all(), 'parent_id', 'parent'), ['id' => 'cat-id']);
echo $form->field($model, 'PARENT_ID')->widget(\kartik\depdrop\DepDrop::classname(), ['options' => ['id' => 'subcat-id'], 'pluginOptions' => ['depends' => ['cat-id'], 'placeholder' => 'Select...', 'url' => Url::to(['get-child'])]]);
?>

    <?php 
echo $form->field($model, 'GRANDCHILD')->textInput(['maxlength' => true]);
?>

    <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();
コード例 #4
0
ファイル: Child.php プロジェクト: adem-team/advanced
 public function getParents()
 {
     return $this->hasOne(Parents::className(), ['parent_id' => 'PARENT_ID']);
 }
コード例 #5
0
 /**
  * Finds the Parents model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Parents the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Parents::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }