Adding UID to the management form so it can be saved and displayed
authorLaury GvR <laury@gaslightmedia.com>
Thu, 19 Oct 2017 20:27:28 +0000 (16:27 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Thu, 19 Oct 2017 20:27:28 +0000 (16:27 -0400)
classes/customFieldPluginSupport.php
models/admin/management/fields.php
setup/adminHooks.php
views/admin/management/fields.html

index c2f8c4a..647a947 100644 (file)
@@ -21,6 +21,7 @@ function customFieldsSaveFields( $memberId )
     if ( !isset( $_REQUEST['glm_custom_field'] ) ) {
         return false;
     }
+    //echo "Trying to save entity of type $uid";
 
     // See if this memberInfo has current field data
     $currentCustomFields = customFieldsGetFields( $memberId );
index 2ce537a..ae387d6 100644 (file)
@@ -132,6 +132,11 @@ class GlmMembersAdmin_management_fields extends GlmDataFieldsCustomFields
         if (isset($_REQUEST['id'])) {
             $id = $_REQUEST['id']-0;
         }
+        $uid = 0;
+        
+        if (isset($actionData['uid'])) {
+            $uid = $actionData['uid'];
+        }
 
         switch ($option) {
 
@@ -180,6 +185,7 @@ class GlmMembersAdmin_management_fields extends GlmDataFieldsCustomFields
 
         // Get list of Custom Fields
         $custom_fields = $this->getList();
+        // echo "<pre>" . print_r($custom_fields, true) . "</pre>";
         if ( isset($custom_fields) && $custom_fields && count( $custom_fields ) > 0 ) {
             $haveCustomFields = true;
         }
@@ -192,6 +198,7 @@ class GlmMembersAdmin_management_fields extends GlmDataFieldsCustomFields
             'custom_fields'       => $custom_fields,
             'field_types'         => $this->config['custom_field_types'],
             'haveCustomFields'    => $haveCustomFields,
+            'uid'                 => $uid
         );
 
         // Return status, suggested view, and data to controller
index dda3f48..cccf024 100644 (file)
@@ -44,8 +44,7 @@ add_filter( 'glm-members-customfields-edit', function( $content, $uid ){
  */
 add_filter( 'glm-members-custom-fields-form', function( $content, $uid, $id ){
     unset( $_REQUEST['glm_action'] );
-    // $content = $this->controller( 'entity', 'fields', array( 'uid' => false, 'memberId' => false ), true );
-    $content = $this->controller( 'entity', 'fields', array('uid'=>$uid, "memberId"=>$id), true );
+    $content = $this->controller( 'entity', 'fields', array( 'uid' => $uid, 'memberId' => $id ), true );
     return $content;
 }, 10, 3 );
 /**
@@ -157,14 +156,14 @@ add_filter('glm-member-db-admin-search-query', function() {
     }
     return $queryParts;
 });
-add_action(
-    'glm-member-db-save-custom-fields',
-    function( $memberInfoId ){
-        require_once GLM_MEMBERS_FIELDS_PLUGIN_CLASS_PATH . '/customFieldPluginSupport.php';
-        // this will save the member data
-        customFieldsSaveFields( $memberInfoId );
+add_filter('glm-member-db-save-custom-fields', function( $entityId ) {
+    require_once GLM_MEMBERS_FIELDS_PLUGIN_CLASS_PATH . '/customFieldPluginSupport.php';
+    // this will save the member data
+    //echo "uid = $uid";
+    customFieldsSaveFields( $entityId );
+    return true;
     },
-    1,
+    10,
     1
 );
 add_action(
index 81a0b92..9cca065 100644 (file)
@@ -38,6 +38,7 @@
                     <input type="checkbox" name="required" value="1" />
                 </td>
             </tr>
+            <input type="hidden" name="uid" value="{$uid}">
         </table>
         <p><span class="glm-required">*</span> Required</p>
         <a id="newFieldCancel" class="button button-primary glm-right">Cancel</a>
             <th>ID</th>
             <th>Field</th>
             <th>Type</th>
+            <th>UID/Entity</th>
+            <th>Required</th>
+            <th>Admin Searchable</th>
             <th>&nbsp;</th>
         </tr>
     </thead>
                 <td id="editFieldType_{$t.id}">
                     {$t.field_type.name}
                 </td>
+                <td>
+                    {$t.uid}
+                </td>
+                <td>
+                    {$t.required.name}
+                </td>
+                <td>
+                    {$t.admin_search.name}
+                </td>
                 <td>
                     <div class="deleteFieldButton button button-secondary glm-button-small glm-right" data-fieldID="{$t.id}">Delete</div>
                 </td>