Zeros not storing / displaying

Permalink Browser Info Environment
My client wanted to have their forms accept 0 (zero) as an answer, but there was some inconsistency with the way Formidable deals with these. I made my own modifications due to time constraints. If you want to implement in your plugin, please feel free to use these modifications:

src/Formidable/Result.php
public function getAnswerByElementID($elementID) {
      $answers = $this->getAnswers();
        if (array_key_exists($elementID, $answers))  {
          if ($answers[$elementID]['answer_unformated'] != '0' || $answers[$elementID]['answer_unformated'] != 0) {
                return unserialize($answers[$elementID]['answer_unformated']);
            } else {
              return $answers[$elementID]['answer_unformated'];
            }
        }
      return false;
   }


src/Formidable/Element.php
public function getSerializedValue() {
      $value = $this->getValue();
      if ((empty($value) && $value != 0 && $value != '0') || (is_array($value) && !count($value))) return '';
      $result['value'] = $value;
      $other = $this->getOtherValue();
      if (!empty($other)) $result['value_other'] = $other;
      return serialize($result);
   }

Type: Discussion
Status: New
afixia
View Replies:

concrete5 Environment Information

# concrete5 Version
Core Version - 8.5.5
Version Installed - 8.5.5
Database Version - 20201116182100

# Database Information
Version: 5.7.12
SQL Mode:

# concrete5 Packages
Afixia: Association Package (0.2.3), Afixia: Login Redirect (0.9.4), Afixia: SEO Redirects (1.1.2), AGC MN (1.0), Block Designer (3.3.0), Devoda SEO (1.5.3), ExchangeCore reCAPTCHA (1.1.1), Formidable (Full Version) (2.1.7.1), Honey Pot (0.9.0.1), Hutman Ads (1.1.4), Location Map (1.0.12), Manual Nav (2.3.3), Pure Accordion (0.9.2), S3 Storage (3.0.3), SCALA Clear Cache (1.1), Whale Galleria (1.2.6), Whale Responsive Tables (1.2.1)

# concrete5 Overrides
blocks/manual_nav/templates/inline.php, blocks/manual_nav/templates, blocks/manual_nav, blocks/page_list/templates/thumbnail_grid/view.css, blocks/page_list/templates/thumbnail_grid/view.php, blocks/page_list/templates/thumbnail_grid, blocks/page_list/templates/blog_list/view.css, blocks/page_list/templates/blog_list/view.php, blocks/page_list/templates/blog_list, blocks/page_list/templates, blocks/page_list, blocks/rss_displayer/view.php, blocks/rss_displayer/templates/events.php, blocks/rss_displayer/templates/home.php, blocks/rss_displayer/templates/sidebar.php, blocks/rss_displayer/templates, blocks/rss_displayer, blocks/page_attribute_display/controller.php, blocks/page_attribute_display/templates/blog_thumb.php, blocks/page_attribute_display/templates, blocks/page_attribute_display, blocks/share_this_page/templates/blog/view.css, blocks/share_this_page/templates/blog/view.php, blocks/share_this_page/templates/blog, blocks/share_this_page/templates, blocks/share_this_page, blocks/express_entry_list/templates/dbe_rfps.php, blocks/express_entry_list/templates, blocks/express_entry_list, blocks/timeline/db.xml, blocks/timeline/composer.php, blocks/timeline/controller.php, blocks/timeline/form.php, blocks/timeline/view.php, blocks/timeline/config.json, blocks/timeline/add.php, blocks/timeline/icon.png, blocks/timeline/edit.php, blocks/timeline, blocks/search/templates/search_top.php, blocks/search/templates, blocks/search, blocks/tags/templates/blog/view.css, blocks/tags/templates/blog/view.php, blocks/tags/templates/blog, blocks/tags/templates, blocks/tags, blocks/pure_accordion/view.css, blocks/pure_accordion/view.php, blocks/pure_accordion/view.js, blocks/pure_accordion, blocks/topic_list/templates/flat_filter.php, blocks/topic_list/templates/blog/view.css, blocks/topic_list/templates/blog/view.php, blocks/topic_list/templates/blog, blocks/topic_list/templates, blocks/topic_list, blocks/next_previous/templates/blog.php, blocks/next_previous/templates, blocks/next_previous, blocks/external_form/country_state.js, blocks/external_form/form/company_registration.php, blocks/external_form/form/foundation_donation.php, blocks/external_form/form/controller/company_registration.php, blocks/external_form/form/controller/foundation_donation.php, blocks/external_form/form/controller/contract_license_request_form.php, blocks/external_form/form/controller/expenditure_donation.php, blocks/external_form/form/controller/toolbox_talks.php, blocks/external_form/form/controller/dues_payment.php, blocks/external_form/form/controller/pac_donation.php, blocks/external_form/form/controller, blocks/external_form/form/contract_license_request_form.php, blocks/external_form/form/expenditure_donation.php, blocks/external_form/form/toolbox_talks.php, blocks/external_form/form/dues_payment.php, blocks/external_form/form/pac_donation.php, blocks/external_form/form, blocks/external_form, blocks/autonav/controller.php, blocks/autonav/nav_item.php, blocks/autonav

# concrete5 Cache Settings
Block Cache - On
Overrides Cache - On
Full Page Caching - Off
Full Page Cache Lifetime - Every 6 hours (default setting).

# Server Software
nginx/1.19.3

# Server API
fpm-fcgi

# PHP Version
7.4.21

# PHP Extensions
bcmath, bz2, calendar, cgi-fcgi, Core, ctype, curl, date, dom, enchant, exif, FFI, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, igbinary, imap, intl, json, libxml, mbstring, memcache, memcached, msgpack, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_mysql, pdo_sqlite, Phar, posix, pspell, readline, redis, Reflection, session, shmop, SimpleXML, soap, sockets, sodium, SPL, sqlite3, standard, swoole, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zip, zlib

# PHP Settings
max_execution_time - 60
log_errors_max_len - 1024
max_file_uploads - 20
max_input_nesting_level - 64
max_input_time - 120
max_input_vars - 1000
memory_limit - 256M
post_max_size - 256M
upload_max_filesize - 256M
mbstring.regex_retry_limit - 1000000
mbstring.regex_stack_limit - 100000
memcache.max_failover_attempts - 20
memcached.sess_lock_max_wait - not set
memcached.sess_lock_wait_max - 150
memcached.sess_server_failure_limit - 0
mysqli.max_links - Unlimited
mysqli.max_persistent - Unlimited
pcre.backtrack_limit - 1000000
pcre.recursion_limit - 100000
redis.pconnect.connection_limit - 0
session.cache_limiter - <i>no value</i>
session.gc_maxlifetime - 7200
soap.wsdl_cache_limit - 5
unserialize_max_depth - 4096
opcache.max_accelerated_files - 7963
opcache.max_file_size - 0
opcache.max_wasted_percentage - 5

Browser User-Agent String

Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You may not request a refund that is not currently owned by you.