Skip to content

Commit 11faa45

Browse files
committed
add application exception for unsupported fields
1 parent 9d552fc commit 11faa45

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

modules/backend/formwidgets/FieldSet.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Backend\FormWidgets;
44

5+
use ApplicationException;
56
use Backend\Classes\FormWidgetBase;
67
use Backend\Widgets\Form;
78

@@ -70,7 +71,14 @@ protected function loadAssets()
7071
*/
7172
public function getFormFields(): array
7273
{
73-
return $this->formWidget->getFields();
74+
$fields = $this->formWidget->getFields();
75+
76+
foreach ($fields as $field) {
77+
if ($this->model->hasRelation($field->fieldName)) {
78+
throw new ApplicationException(trans('backend::lang.fieldset.relation-not-supported',['field' => $field->fieldName]));
79+
}
80+
}
81+
return $fields;
7482
}
7583

7684
/**

modules/backend/lang/en/lang.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@
244244
'column_switch_true' => 'Yes',
245245
'column_switch_false' => 'No',
246246
],
247+
'fieldset' => [
248+
'relation-not-supported' => ':field: model relation fields are not supported by the fieldset formwidget',
249+
],
247250
'fileupload' => [
248251
'attachment' => 'Attachment',
249252
'help' => 'Add a title and description for this attachment.',

0 commit comments

Comments
 (0)