Skip to content

Commit 4f6ae1d

Browse files
committed
Reference fields use default filter to remove disabled items
1 parent 1e3f266 commit 4f6ae1d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Form.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ public function build($field_name = null, $overrides = []) {
6363
if ($this->model->fieldType($field_name) == 'reference') {
6464
// Get list of possible results
6565
$refmodel = $this->model->refModel($field_name);
66-
$options = $refmodel::find_pairs_representation();
66+
$options = $refmodel::defaultFilter()->find_pairs_representation();
67+
if (!array_key_exists($this->model->$field_name, $options)) {
68+
foreach ($refmodel::where_id($this->model->$field_name)->find_pairs_representation() as $id => $representation) {
69+
$options[$id] = $representation;
70+
}
71+
}
6772
}
6873
if ($this->model->fieldType($field_name) == 'enum') {
6974
$options = $this->model->enum_options($field_name);

0 commit comments

Comments
 (0)