| @@ -2,8 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace BitCode\BitForm\API\BitForm_Public; |
| 4 | 4 | |
| 5 | 5 | use BitCode\BitForm\Core\Database\ApiModel; |
| 6 | +use BitCode\BitForm\Core\Util\Utilities; | |
| 6 | 7 | |
| 7 | 8 | class BitForm_Public |
| 8 | 9 | { |
| 9 | 10 | public static function getForms() |
| @@ -18,12 +19,16 @@ | ||
| 18 | 19 | $db = new ApiModel(); |
| 19 | 20 | $formData = $db->getField($formId); |
| 20 | 21 | if (!empty($formData)) { |
| 21 | 22 | $unset_types = ['paypal', 'razorpay', 'stripe', 'recaptcha', 'hcaptcha']; |
| 22 | - $formContent = json_decode($formData[0]->form_content); | |
| 23 | + $formRow = Utilities::firstRow($formData); | |
| 24 | + $formContent = Utilities::jsonObj($formRow->form_content ?? ''); | |
| 25 | + if (!$formContent || !isset($formContent->fields)) { | |
| 26 | + return (object) []; | |
| 27 | + } | |
| 23 | 28 | foreach ($formContent->fields as $key => $field) { |
| 24 | 29 | if (in_array($field->typ, $unset_types)) { |
| 25 | - unset($formContent->fields->{$key}, $fieldsKey[$key]); | |
| 30 | + unset($formContent->fields->{$key}); | |
| 26 | 31 | } |
| 27 | 32 | } |
| 28 | 33 | return $formContent->fields; |
| 29 | 34 | } |