# Custom class-gf-field $value is never an array

**URL:** <https://community.gravityforms.com/t/custom-class-gf-field-value-is-never-an-array/4418>\
**Category:** Get Help\
**Tags:** custom, has-ticket, class-gf-field-contact\
**Created:** [April 10, 2020, 7:37am UTC](https://community.gravityforms.com/t/custom-class-gf-field-value-is-never-an-array/4418 "2020-04-10T07:37:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Inline\_Media](https://avatars.discourse-cdn.com/v4/letter/i/ba9def/32.png) [@Inline\_Media](https://community.gravityforms.com/u/Inline_Media)\
**Post date:** [April 10, 2020, 7:37am UTC](https://community.gravityforms.com/t/custom-class-gf-field-value-is-never-an-array/4418/1 "2020-04-10T07:37:18Z")

</div>

I made a custom class-gf-field-contact with multiple inputs but the $value is always a string, never an array. Even when I duplicate “class-gf-field-address.php”, only change the class name and $type it still doesn’t return $value as an array.

Can anyone help me out? 🤔

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [April 10, 2020, 2:21pm UTC](https://community.gravityforms.com/t/custom-class-gf-field-value-is-never-an-array/4418/2 "2020-04-10T14:21:09Z")

</div>

Can you share your code, so we can give it a try?

---

<div class="post-metadata">

**Author:** ![Inline\_Media](https://avatars.discourse-cdn.com/v4/letter/i/ba9def/32.png) [@Inline\_Media](https://community.gravityforms.com/u/Inline_Media)\
**Post date:** [April 10, 2020, 2:34pm UTC](https://community.gravityforms.com/t/custom-class-gf-field-value-is-never-an-array/4418/3 "2020-04-10T14:34:53Z")

</div>

Yes ofcourse.

> <https://gist.github.com/MDRietveld/1253a5c0fc1ea43d540235e4a7f36b92>

  
The first php file “bla” is a copy of address, which doesn’t work. The second is my own contact field. Ofcourse I also included these files in my functions.php

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [April 10, 2020, 6:10pm UTC](https://community.gravityforms.com/t/custom-class-gf-field-value-is-never-an-array/4418/4 "2020-04-10T18:10:00Z")

</div>

Hi Martijn. I see that you also opened a support ticket, and Richard replied to that. If you would like to share the resolution here, please do that once it’s all resolved. Thank you.

---

<div class="post-metadata">

**Author:** ![Inline\_Media](https://avatars.discourse-cdn.com/v4/letter/i/ba9def/32.png) [@Inline\_Media](https://community.gravityforms.com/u/Inline_Media)\
**Post date:** [April 14, 2020, 7:48am UTC](https://community.gravityforms.com/t/custom-class-gf-field-value-is-never-an-array/4418/5 "2020-04-14T07:48:03Z")

</div>

Hi Chris. I Indeed also opened a support ticket.  
For the community:  
My fields were not showing in the editor until I saved my edits, when I refreshed they were not visible anymore.  
What solved this problem was putting the custom fields inside a custom plugin.

The values problem was fixed with this:

> **[How to Set the Default Properties for a New Field - Gravity Forms](https://docs.gravityforms.com/set-default-properties-new-field/)**
>
> This article shows how the SetDefaultValues\_ function can be used with get\_form\_editor\_inline\_script\_on\_page\_render() to set the default properties for a new field.

  
IMPORTANT: For this to work you have to remove the field from the form, than add it again. I’ve updated the gist, removed the class-gf-field-ba.php, modified the class-gf-field-contact.php. The contact class works for me, the function “get\_form\_editor\_inline\_script\_on\_page\_render” was the missing piece

---

<div class="post-metadata">

**Author:** ![richardw8k](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/richardw8k/32/2354_2.png) [@richardw8k](https://community.gravityforms.com/u/richardw8k)\
**Post date:** [January 5, 2022, 8:49am UTC](https://community.gravityforms.com/t/custom-class-gf-field-value-is-never-an-array/4418/6 "2022-01-05T08:49:10Z")

</div>


