Author Topic: Customfield STRING and zero  (Read 850 times)

jflash

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 28
Customfield STRING and zero
« on: December 21, 2017, 18:57:26 pm »
Hello!
I have customfield type string. I need put in this field numbers, including zero. All OK, but zero does not saves in database - if i reopen product, this field has nothing. Even if i make new customfield, type text, same thing happening - zero does not saves in database, field empty after saving product...

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3152
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Customfield STRING and zero
« Reply #1 on: December 22, 2017, 01:11:53 am »
Hi, you need to check for strlen
Change
if (!empty($selected['comment'])) {
to
if (strlen($selected['comment'])) {

I tested it on my own plugin, i have do the same mistake in my enhanced textinput plugin.

jflash

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 28
Re: Customfield STRING and zero
« Reply #2 on: December 22, 2017, 07:15:58 am »
But how make STRING customfield to work with zero?

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 1540
    • Kreativ Fotografi
  • VirtueMart Version: 3.2.12
Re: Customfield STRING and zero
« Reply #3 on: December 22, 2017, 07:59:05 am »
Hello

Somehow this type understands the digit zero as no input. I am not sure that this is intended. Could You insert the Word ZERO instead ?
Or are You using the field for calculations ?

regards

Jörgen @ Kreativ Fotografi
Joomla 3.8.3
Virtuemart 3.2.12
Olympiantheme Hera (customized)

jflash

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 28
Re: Customfield STRING and zero
« Reply #4 on: December 22, 2017, 08:30:51 am »
I have products with parameters and this parameters i use in CustomFilters. And i need parameter 0 (zero) for filtering products. I cant use o (letter) because in filters where all parameters are numbers goes this o (letter) to bottom of number list...

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3152
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Customfield STRING and zero
« Reply #5 on: December 22, 2017, 10:09:40 am »
Have you try -1 ?

jflash

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 28
Re: Customfield STRING and zero
« Reply #6 on: December 22, 2017, 10:12:31 am »
-1 works, -0 works too, but 0 does not

jflash

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 28
Re: Customfield STRING and zero
« Reply #7 on: December 24, 2017, 20:35:47 pm »
OK, zero is not number and i can nothing to do?

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3152
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Customfield STRING and zero
« Reply #8 on: December 25, 2017, 11:24:05 am »
use another char, eg - or + that are before 0 in the ascii table should ordering correctly