@@ -88,7 +88,6 @@ protected function fillTabs(array $tabs, SimpleElement $element = null)
88
88
$ tab = $ this ->getTab ($ tabName );
89
89
$ this ->openTab ($ tabName );
90
90
$ tab ->fillFormTab (array_merge ($ tabFields , $ this ->unassignedFields ), $ context );
91
- $ this ->updateUnassignedFields ($ tab );
92
91
}
93
92
if (!empty ($ this ->unassignedFields )) {
94
93
$ this ->fillMissedFields ($ tabs );
@@ -97,19 +96,6 @@ protected function fillTabs(array $tabs, SimpleElement $element = null)
97
96
return $ this ;
98
97
}
99
98
100
- /**
101
- * Update array with fields which aren't assigned to any tab
102
- *
103
- * @param Tab $tab
104
- */
105
- protected function updateUnassignedFields (Tab $ tab )
106
- {
107
- $ this ->unassignedFields = array_diff_key (
108
- $ this ->unassignedFields ,
109
- array_intersect_key ($ this ->unassignedFields , $ tab ->setFields )
110
- );
111
- }
112
-
113
99
/**
114
100
* Fill fields which weren't found on filled tabs
115
101
*
@@ -120,11 +106,17 @@ protected function updateUnassignedFields(Tab $tab)
120
106
*/
121
107
protected function fillMissedFields (array $ tabs )
122
108
{
123
- foreach (array_diff_key ( $ this ->tabs , $ tabs ) as $ tabName => $ tabData ) {
109
+ foreach ($ this ->tabs as $ tabName => $ tabData ) {
124
110
$ tab = $ this ->getTab ($ tabName );
125
- if ($ this ->openTab ($ tabName )) {
126
- $ tab ->fillFormTab ($ this ->unassignedFields , $ this ->_rootElement );
127
- $ this ->updateUnassignedFields ($ tab );
111
+ if ($ this ->openTab ($ tabName ) && $ this ->isTabVisible ($ tabName )) {
112
+ $ mapping = $ tab ->dataMapping ($ this ->unassignedFields );
113
+ foreach ($ mapping as $ fieldName => $ data ) {
114
+ $ element = $ tab ->_rootElement ->find ($ data ['selector ' ], $ data ['strategy ' ], $ data ['input ' ]);
115
+ if ($ element ->isVisible ()) {
116
+ $ element ->setValue ($ data ['value ' ]);
117
+ unset($ this ->unassignedFields [$ fieldName ]);
118
+ }
119
+ }
128
120
if (empty ($ this ->unassignedFields )) {
129
121
break ;
130
122
}
0 commit comments