File tree Expand file tree Collapse file tree 3 files changed +23
-14
lines changed
Expand file tree Collapse file tree 3 files changed +23
-14
lines changed Original file line number Diff line number Diff line change 33namespace Backend \FormWidgets ;
44
55use ApplicationException ;
6+ use Backend \Classes \FormField ;
67use Backend \Classes \FormWidgetBase ;
78use Backend \Widgets \Form ;
89
@@ -71,14 +72,15 @@ protected function loadAssets()
7172 */
7273 public function getFormFields (): array
7374 {
74- $ fields = $ this ->formWidget ->getFields ();
75+ return $ this ->formWidget ->getFields ();
76+ }
7577
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 ;
78+ /**
79+ * return an internal formwidget's formWidget
80+ */
81+ public function getFormWidget ( $ field ): FormWidgetBase
82+ {
83+ return $ this -> formWidget -> getFormWidget ( $ field ) ;
8284 }
8385
8486 /**
@@ -94,4 +96,12 @@ public function prepareVars()
9496 {
9597 $ this ->formWidget ->previewMode = $ this ->previewMode ;
9698 }
99+
100+ /**
101+ * @inheritDoc
102+ */
103+ public function getSaveValue ($ value )
104+ {
105+ return $ this ->formWidget ->getSaveValue ($ value );
106+ }
97107}
Original file line number Diff line number Diff line change 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- ],
250247 'fileupload ' => [
251248 'attachment ' => 'Attachment ' ,
252249 'help ' => 'Add a title and description for this attachment. ' ,
Original file line number Diff line number Diff line change 66use Backend \Classes \FormWidgetBase ;
77use Backend \Classes \WidgetBase ;
88use Backend \Classes \WidgetManager ;
9+ use Backend \FormWidgets \FieldSet ;
910use BackendAuth ;
1011use Exception ;
1112use Form as FormHelper ;
@@ -1222,20 +1223,21 @@ public function getSaveData(): array
12221223 }
12231224
12241225 // get nested widget fields that should be saved to the model
1225- if (method_exists ( $ widget, ' getFormFields ' ) ) {
1226+ if ($ widget instanceof FieldSet ) {
12261227 foreach ($ widget ->getFormFields () as $ field ) {
12271228 $ parts = HtmlHelper::nameToArray ($ field ->fieldName );
12281229 if (($ value = $ this ->dataArrayGet ($ data , $ parts )) !== null ) {
1229- /*
1230- * Number fields should be converted to integers
1231- */
12321230 if ($ field ->type === 'number ' ) {
12331231 $ value = !strlen (trim ($ value )) ? null : (float ) $ value ;
12341232 }
1233+ if ($ field ->type === 'widget ' ) {
1234+ $ value = $ widget ->getFormWidget ($ field ->fieldName )->getSaveValue ($ value );
1235+ }
12351236
12361237 $ this ->dataArraySet ($ result , $ parts , $ value );
12371238 }
12381239 }
1240+ continue ;
12391241 }
12401242
12411243 // Exclude fields that didn't provide any value
You can’t perform that action at this time.
0 commit comments