@@ -15,6 +15,7 @@ class api extends cmsFrontend {
1515 private $ output_error = array ();
1616
1717 public $ key = null ;
18+ public $ method_name = null ;
1819
1920 public function __construct ($ request ){
2021
@@ -125,7 +126,7 @@ public function actionExecute() {
125126
126127 if (!$ method_result ){ return $ this ->error (13 ); }
127128
128- $ response [$ method_param ['method ' ]] = $ this ->output_success ['response ' ];
129+ $ response [! empty ( $ method_param [ ' key ' ]) ? $ method_param [ ' key ' ] : $ method_param ['method ' ]] = $ this ->output_success ['response ' ];
129130
130131 }
131132
@@ -268,7 +269,7 @@ function api_image_src($images, $size_preset = false){
268269}
269270function form_to_params ($ form ) {
270271
271- $ params = array (array (
272+ $ params = array (' csrf_token ' => array (
272273 'title ' => 'csrf_token ' ,
273274 'fields ' => array (
274275 array (
@@ -293,7 +294,7 @@ function form_to_params($form) {
293294
294295 $ structure = $ form ->getStructure ();
295296
296- foreach ($ structure as $ fieldset ){
297+ foreach ($ structure as $ key => $ fieldset ){
297298
298299 if (empty ($ fieldset ['childs ' ])) { continue ; }
299300
@@ -304,20 +305,21 @@ function form_to_params($form) {
304305
305306 foreach ($ fieldset ['childs ' ] as $ field ){
306307
307- $ param ['fields ' ][] = array (
308+ $ param ['fields ' ][$ field -> getName () ] = array (
308309 'title ' => $ field ->title ,
309310 'type ' => $ field ->class ,
310311 'name ' => $ field ->getName (),
311312 'rules ' => $ field ->getRules (),
312313 'var_type ' => $ field ->var_type ,
313314 'items ' => (method_exists ($ field , 'getListItems ' ) ? $ field ->getListItems () : null ),
314315 'hint ' => (!empty ($ field ->hint ) ? $ field ->hint : null ),
316+ 'units ' => (!empty ($ field ->units ) ? $ field ->units : null ),
315317 'default ' => (isset ($ field ->default ) ? $ field ->default : null )
316318 );
317319
318320 }
319321
320- $ params [] = $ param ;
322+ $ params [$ key ] = $ param ;
321323
322324 }
323325
0 commit comments