From 8ec80c9733f470783ffe2d4e2b8b07819be1c146 Mon Sep 17 00:00:00 2001 From: weryques Date: Thu, 1 Mar 2018 14:56:36 -0300 Subject: [PATCH] Fixes prepare item from db in fields controller --- .../class-tainacan-rest-fields-controller.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/api/endpoints/class-tainacan-rest-fields-controller.php b/src/api/endpoints/class-tainacan-rest-fields-controller.php index 8e2630e35..49309d8f5 100644 --- a/src/api/endpoints/class-tainacan-rest-fields-controller.php +++ b/src/api/endpoints/class-tainacan-rest-fields-controller.php @@ -117,16 +117,16 @@ class TAINACAN_REST_Fields_Controller extends TAINACAN_REST_Controller { $collection = new Entities\Collection( $collection_id ); $field->set_collection( $collection ); - } + } else { + $meta = json_decode( $request, true ); + foreach ( $meta as $key => $value ) { + $set_ = 'set_' . $key; + $field->$set_( $value ); + } - $meta = json_decode($request, true); - foreach ( $meta as $key => $value ) { - $set_ = 'set_' . $key; - $field->$set_( $value ); + $field->set_collection_id( 'default' ); } - $field->set_collection_id('default'); - return $field; }