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.081 seconds

Awards for the best Joomla app. This product is gonna win an award for this amazing job. Cook Self Service is the the best application from all over the Joomla universe ! It brings Joomla to a professional level really advanced for developers. It is a real fun to develop with it. The ACL part and security checks implementation are just... so much hours saved. I can now concentrate myself more on the design part and the creative works. Thank you so much. Guys I offer you all my congratulation ! Keep up the works because Joomla is needing it to increase the quality of extensions availables on the JED. I also learned a lot because I can see how to code at the proper place and I found all my answers reading the forum.
lack_hanson (JED)
          

Get Started