Przeglądaj źródła

Ticket #4558 - Build-in API support: Preselect context in Create Forms.

AntonLV 1 rok temu
rodzic
commit
0d307639b9

+ 9 - 0
template/scripts/BxBaseFormView.php

@@ -434,6 +434,15 @@ class BxBaseFormView extends BxDolForm
                         return ['key' => $sKey, 'value' => $aInput['values'][$sKey]];
                     }, array_keys($aInput['values']));
                 }
+
+                if(isset($aInput['name']) && $aInput['name'] == 'allow_view_to') {
+                    //--- Preselect Context ID if available
+                    if(($aParams = bx_get('params')) !== false && isset($aParams['context_id']) && ($iContextId = (int)$aParams['context_id']) < 0)
+                        $aInput = array_merge($aInput, [
+                            'type' => 'hidden',
+                            'value' => $iContextId
+                        ]);
+                }
             }
             else{
                 $keysToRemove[] = $key;

+ 5 - 2
template/scripts/BxBaseServices.php

@@ -714,8 +714,11 @@ class BxBaseServices extends BxDol implements iBxDolProfileService
         if(bx_is_api()) {
             return [
                 'title' => $sTitle,
-                'content' => '',
-                'menu' => $oMenu->getCodeAPI()
+                'content' =>  [
+                    bx_api_get_block('get_create_post_form', [
+                        'menu' => $oMenu->getCodeAPI(),
+                        'params' => ['context_id' => $mixedContextId]])
+                ]
             ];
         }