Welcome, Guest
Username: Password: Remember me

TOPIC: [CLOSED] save2copy not working, bug or not?

save2copy not working, bug or not? 31 Jan 2013 14:03 #6599

  • Tomaselli
  • Tomaselli's Avatar
  • Offline
  • Elite Member
  • Posts: 293
  • Thank you received: 87
  • Karma: 46
Hi,
I just saw the save2copy doesn't work on my component.

I don't know the reason, and I couldn't have the time to check.
It doesn't work on the builder sandbox and either in localhost.

I would like to know if it's just me, my account, or something it happens also to someone else.

here my workaround:

add this function to the the following file:
ROOT_YOUR_SITE\administrator\components\com_your_component\classes\jmodel.item.php

	public function save($data)
	{
		$jinput = new JInput;
		if (in_array($jinput->get('task'), array('save2copy'))){
			$data['id'] = 0;
		}
		
		parent::save($data);

		return true;
	}
The administrator has disabled public write access.

Re: save2copy not working, bug or not? 31 Jan 2013 14:38 #6600

  • Tomaselli
  • Tomaselli's Avatar
  • Offline
  • Elite Member
  • Posts: 293
  • Thank you received: 87
  • Karma: 46
I also noticed, if you wanna save your data using the model (by code).
the new items are not saved correctly, due to the "user state", what "remember" the last item manipulated by the user.

So the new item data you would save will be "mixed" with the LAST item used by the user.

so, here my workaround:
add this function to the the following file:
ROOT_YOUR_SITE\administrator\components\com_your_component\classes\jmodel.item.php
	public function saveNew($data)
	{
		$this->setState($this->getName() . '.id', 0);
		parent::save($data);

		return true;
	}

when you wanna save a new item, using the MODEL, just call this new function.
The administrator has disabled public write access.

Re: save2copy not working, bug or not? 01 Feb 2013 15:31 #6610

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Hi @Tomaselli,

I'm afraid I only tried save2copy a long time ago so I don't know about this.

Will post message to @admin to see if he's aware or can make suggestions/accept your proposed code.

Thanks again!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: save2copy not working, bug or not? 06 Feb 2013 16:40 #6651

  • dyoungers
  • dyoungers's Avatar
  • Offline
  • Premium Member
  • Posts: 123
  • Thank you received: 16
  • Karma: 0
After looking at this, it appears to me that this code could just be combined in the save function, or am I missing somthing? The following code seems to work for me ...
public function save($data)
	{
		$jinput = new JInput;
		if (in_array($jinput->get('task'), array('save2copy'))){
			$data['id'] = 0;
			$this->setState($this->getName() . '.id', 0);
		}
		
		parent::save($data);

		return true;
	}

Dave
The administrator has disabled public write access.
Time to create page: 0.069 seconds

Get Started