Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

[FIXED] Boolean in backend item is always 1 30 Dec 2011 14:31 #773

I have created a Publish field in several tables. I used the Publish wizard. I also set the default value to 1.

In the backend i have created an item form and put the Publish field into the form.

Now when i save an item with the Publish radiobox to No it will save a value 1 (Yes).

The reason is in the code in the table class check() function:
if (empty($this->publish))
			$this->publish = "1";

When you look at the return values of the php empty function a zero is considered as empty:
Returns FALSE if var has a non-empty and non-zero value.

The following things are considered to be empty:

"" (an empty string)
0 (0 as an integer)
0.0 (0 as a float)
"0" (0 as a string)
NULL
FALSE
array() (an empty array)
var $var; (a variable declared, but without a value in a class)


I think in case of a boolean the check with empty(value) is not correct because 0 is the No value!
Molenwal1 Webdesign
www.molenwal1.nl

Please Log in or Create an account to join the conversation.

Last edit: by molenwal1.

Re: Boolean in backend item is always 1 30 Dec 2011 14:57 #774

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Try with:

if ($this->publish === null)
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

Re: Boolean in backend item is always 1 02 Jan 2012 06:01 #788

Ok, that works, maybe an idea to change this in the cook for boolean fields. When someone creates a boolean field in a form the same problem will occur.
Molenwal1 Webdesign
www.molenwal1.nl

Please Log in or Create an account to join the conversation.

Re: Boolean in backend item is always 1 03 Jan 2012 21:19 #806

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Solved Since 1.4.6
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.086 seconds
  I still don't believe he can really be human to do all this ! From all of the forums that I've ever participated in this is certainly the one that most encapsulates the feeling of being truly open source where everyone's opinions and contributions can and will shape the development of the service! It's truly awesome! Hope you enjoy cooking and look forward to reading and contributing to any of the editorial work that you proposed too!! Thanks
Gez (audibleid - JED)

Get Started