Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 244e07f

Browse files
committedJan 20, 2021
fix guessed "their_field"
1 parent 2fe8e65 commit 244e07f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed
 

‎demos/form-control/dropdown-plus.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
$form->addControl('category_id', [Form\Control\Dropdown::class, 'model' => new Category($app->db)]);
2323
$form->addControl('sub_category_id', [Form\Control\DropdownCascade::class, 'cascadeFrom' => 'category_id', 'reference' => Category::hinting()->fieldName()->SubCategories]);
24-
// DEBUG only, uncomment before merge!!! $form->addControl('product_id', [Form\Control\DropdownCascade::class, 'cascadeFrom' => 'sub_category_id', 'reference' => SubCategory::hinting()->fieldName()->Products]);
24+
$form->addControl('product_id', [Form\Control\DropdownCascade::class, 'cascadeFrom' => 'sub_category_id', 'reference' => SubCategory::hinting()->fieldName()->Products]);
2525

2626
$form->onSubmit(function (Form $form) use ($app) {
2727
$message = $app->encodeJson($form->model->get());

‎demos/init-db.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ protected function init(): void
223223
$this->addField($this->fieldName()->type, ['caption' => 'MIME Type']);
224224
$this->addField($this->fieldName()->is_folder, ['type' => 'boolean']);
225225

226-
$this->hasMany($this->fieldName()->SubFolder, ['model' => [self::class], 'their_field' => $this->fieldName()->parent_folder_id])
226+
$this->hasMany($this->fieldName()->SubFolder, ['model' => [self::class], 'their_field' => self::hinting()->fieldName()->parent_folder_id])
227227
->addField($this->fieldName()->count, ['aggregate' => 'count', 'field' => $this->persistence->expr($this, '*')]);
228228

229229
$this->hasOne($this->fieldName()->parent_folder_id, ['model' => [Folder::class]])
@@ -304,8 +304,8 @@ protected function init(): void
304304
parent::init();
305305
$this->addField($this->fieldName()->name);
306306

307-
$this->hasMany($this->fieldName()->SubCategories, ['model' => [SubCategory::class]]);
308-
$this->hasMany($this->fieldName()->Products, ['model' => [Product::class]]);
307+
$this->hasMany($this->fieldName()->SubCategories, ['model' => [SubCategory::class], 'their_field' => SubCategory::hinting()->fieldName()->product_category_id]);
308+
$this->hasMany($this->fieldName()->Products, ['model' => [Product::class], 'their_field' => Product::hinting()->fieldName()->product_category_id]);
309309
}
310310
}
311311

@@ -325,7 +325,7 @@ protected function init(): void
325325
$this->addField($this->fieldName()->name);
326326

327327
$this->hasOne($this->fieldName()->product_category_id, ['model' => [Category::class]]);
328-
$this->hasMany($this->fieldName()->Products, ['model' => [Product::class]]);
328+
$this->hasMany($this->fieldName()->Products, ['model' => [Product::class], 'their_field' => Product::hinting()->fieldName()->product_category_id]);
329329
}
330330
}
331331

0 commit comments

Comments
 (0)
Please sign in to comment.