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

TOPIC:

[FIXED] Toggle + authoring 08 May 2012 12:30 #2284

Hi Admin,
I'm not in the position of tell you what to do, so I apologize in advance for the following review, it's just a way to give you an idea on how fix quickly the following bugs.

scenario:

- table with authoring feature
- boolean toggle field with default value = TRUE
- grid view with toggle function on that field


bug:
1) with "edit own" enabled, toggle not working
2) if the above bug is bypassed, toggle function not working, because I get a message DONE but the value is ALWAYS "TRUE", so it doesn't toggle anything.


Bugs reasons and Fixes (backend / frontend):
1) in the toggle function in the controllers file at the line:
		if (!$this->can('core.edit', JText::_("COMPONENTNAME_JTOOLBAR_EDIT")))
			return;

that line should be:
		if (!$this->can(array('core.edit', 'core.edit.own'), JText::_("COMPONENTNAME_JTOOLBAR_EDIT")))
			return;

2) always in the same controller file and in the same function at the line:
		$data["your_toggle_field"] = !$componentitem->your_toggle_field;


that line should be (surely it is not nice looking like the original, but it works with no doubts):
		if ($componentitem->your_toggle_field == 1) {
			$data["your_toggle_field"] = 0;
		} else {
			$data["your_toggle_field"] = 1;
		}

the bug is not fixed yet, we have to go to the TABLE file in the backend at the line:
	/**
	 * @var bool
	 */
	var $your_toggle_field = null;

and replace the value with our default value, in my case TRUE so it will be 1:
	/**
	 * @var bool
	 */
	var $your_toggle_field = 1;


then down to the CHECK function at the line:
		if ($this->your_toggle_field == null)
			$this->your_toggle_field = 1;

we have to delete those two lines that caused the bug.

Moreover, I have noticed sometimes the toggle function in the controllers files, for some weird reason, is not rendered (but in the builder everything is configured correctly), so the workaround to have the toggle function working is to delete from the TABLE in the builder the YOUR_TOGGLE_FIELD and recreate it.

I'm sure the Admin will find a better way to fix these bugs in the builder.
thanks in advance for the support.
The following user(s) said Thank You: VeCrea

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

Last edit: by Tomaselli.

Re: Few things wrong on the TOGGLE feature rendering 10 May 2012 13:49 #2305

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Many thanks.


Fixed now.

I applied a different code, but yours is working and has been written in correct maneer.

A detail, Cook considers 3 states (TRUE, FALSE, null), so the second part of your code is wrong.
If you want to avoid null value, you only have to specify a default value.
Coding is now a piece of cake

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

Re: Few things wrong on the TOGGLE feature rendering 10 May 2012 19:06 #2310

Hi Admin,
thanks for the reply and thanks to have fixed it. but there is still a bug.
you are right there are 3 states, I knew that (in anycase the null state doesn't have any meaning if there is a default value that isn't null). the problem is.....it still doesn't work. Now it has another bug the "0" (FALSE state) is converted to NULL and, due to the following lines, it is consequently converted to TRUE:
		if ($this->your_toggle_field == null)
			$this->your_toggle_field = 1;
removing the above lines is a workaround, the problem is where the FALSE state becomes null (it shouldn't), I don't have time now to see where it happens, tomorrow I'll take a look.
The following user(s) said Thank You: admin

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

Re: Few things wrong on the TOGGLE feature rendering 11 May 2012 12:57 #2314

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Fixed.
if ($this->your_toggle_field === null)   // 3 '=' signs for detecting REAL null value.
	$this->your_toggle_field = 1;
Coding is now a piece of cake
The following user(s) said Thank You: Tomaselli

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

Re: Few things wrong on the TOGGLE feature rendering 11 May 2012 13:54 #2315

Thanks!
Surely I will not forget what 3 '=' means :)

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

  • Page:
  • 1
Time to create page: 0.099 seconds

First of all... I have to congratulate you guys for the awesome tool... I came here only to see what this thing was up to and I have to tell that I'm very impressed with what this tool can do. French guys are making a revolution on Joomla... first with Seblod and now Cook...
Griiettner (forum)

Get Started