Title: [PATCH] Invalid argument in fields.php
Last modified: August 20, 2016

---

# [PATCH] Invalid argument in fields.php

 *  Resolved [flynsarmy](https://wordpress.org/support/users/flynsarmy/)
 * (@flynsarmy)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/patch-invalid-argument-in-fieldsphp/)
 * With WP_DEBUG on I’m getting a couple of warnings on my WP admin dashboard.
 * > Warning: Invalid argument supplied for foreach() in /path/to/wp-content/plugins/
   > types/embedded/includes/fields.php on line 76
 * This is the line in question:
 *     ```
       foreach ( $fields as $k => $v ) {
       ```
   
 * I did a `var_dump($fields)` and it looks like a `false` boolean was being passed.
   Simple fix is to add the line:
 *     ```
       if ( is_array($fields) )
       ```
   
 * above the foreach.
 * Second was:
 * > Warning: Invalid argument supplied for foreach() in /path/to/wp-content/plugins/
   > types/embedded/classes/conditional.php on line 82
 * which is
 *     ```
       foreach ( $fields->fields->all as $f_id => $f ) {
       ```
   
 * Again, all is a false boolean so I added
 *     ```
       if ( is_array($fields->fields->all) )
       ```
   
 * above the foreach.
 * [http://wordpress.org/extend/plugins/types/](http://wordpress.org/extend/plugins/types/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Contributor [brucepearson](https://wordpress.org/support/users/brucepearson/)
 * (@brucepearson)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/patch-invalid-argument-in-fieldsphp/#post-3548067)
 * Are you seeing this error with Types 1.2?
 *  Thread Starter [flynsarmy](https://wordpress.org/support/users/flynsarmy/)
 * (@flynsarmy)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/patch-invalid-argument-in-fieldsphp/#post-3548071)
 * Yes. My guess is I have a field group with no fields. Haven’t checked to confirm
   yet. Just wanted to get rid of the warnings so I wrote the patch.
 *  Plugin Contributor [brucepearson](https://wordpress.org/support/users/brucepearson/)
 * (@brucepearson)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/patch-invalid-argument-in-fieldsphp/#post-3548170)
 * Thanks, we’ll include this in the next release that will be out soon.
 *  [nikkione](https://wordpress.org/support/users/nikkione/)
 * (@nikkione)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/patch-invalid-argument-in-fieldsphp/#post-3548244)
 * I have the same problem with types 1.2 wp3.5.1 and php 5.4!!
    and one more:
 * >  Warning: Invalid argument supplied for foreach() in /path/wp-content/plugins/
   > types/embedded/admin.php on line 423
 * this is the line in question
    `foreach ( $messages_for_user as $message_id =>
   $message ) {` i added `if ( is_array($messages_for_user) )` above the foreach,
   and all works.
 * Thanks, **flynsarmy** for fix and help.
 *  [jozik](https://wordpress.org/support/users/jozik/)
 * (@jozik)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/patch-invalid-argument-in-fieldsphp/#post-3548246)
 * Thanks, we included fix for this too.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘[PATCH] Invalid argument in fields.php’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/types_ced1d3.svg)
 * [Toolset Types - Custom Post Types, Custom Fields and Taxonomies](https://wordpress.org/plugins/types/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/types/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/types/)
 * [Active Topics](https://wordpress.org/support/plugin/types/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/types/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/types/reviews/)

 * 5 replies
 * 4 participants
 * Last reply from: [jozik](https://wordpress.org/support/users/jozik/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/patch-invalid-argument-in-fieldsphp/#post-3548246)
 * Status: resolved