Hi AllAs you will all know the JRequest is decrepated in Joomla 2.5. So I am changing lines likeJRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN'));$requestData = JRequest::getVar('jform', array(), 'post', 'array');intoglobal $app;JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));$requestData = $app->input->post->get('jform', array(), 'array');But what is the right one forJRequest::setVar('jform', $requestData, 'post');?Because$app->input->post->set('jform', $requestData);is not working.I use this kind of code in the save function of the backend controller likepublic function save(){global $app;JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));$requestData = $app->input->post->get('jform', array(), 'array');$date = date("Y-m-d H:i:s");$requestData['date_modify'] = $date;JRequest::setVar('jform', $requestData, 'post'); // this one needs to be changedparent::save();}When the parent save is called the $data var doesnt have that date_modify changes.In fact the parent save uses the JRequest::getVar.
array 'id' => string '4' (length=1) 'company_id' => string '1' (length=1) 'table_name' => string 'client' (length=6) 'parent_id' => string '5' (length=1) 'type' => string '1001' (length=4) 'primary_address' => string '0' (length=1) 'address' => string 'Gravendreef' (length=11) 'address_nr' => string '89000111' (length=8) 'zip_code' => string '8888HH' (length=6) 'city' => string 'Den Haag' (length=8) 'phone_number' => string '' (length=0) 'fax_number' => string '' (length=0) 'email' => string '' (length=0) 'published' => string '1' (length=1) 'date_modified' => string '2013-03-19 20:43:42' (length=19)
after setting some vars
$date = date("Y-m-d H:i:s");
$requestData['date_modified'] = $date;
$requestData['parent_id'] = $app->getUserState('address-parent_id');
$requestData['published'] = 1;
$requestData['table_name'] = $app->getUserState('address-location');
array 'id' => string '4' (length=1) 'company_id' => string '1' (length=1) 'table_name' => string 'client' (length=6) 'parent_id' => string '5' (length=1) 'type' => string '1001' (length=4) 'primary_address' => string '0' (length=1) 'address' => string 'Gravendreef' (length=11) 'address_nr' => string '89000111' (length=8) 'zip_code' => string '8888HH' (length=6) 'city' => string 'Den Haag' (length=8) 'phone_number' => string '' (length=0) 'fax_number' => string '' (length=0) 'email' => string '' (length=0) 'published' => int 1 'date_modified' => string '2013-03-21 08:37:35' (length=19)
$jInput->input->post->set('jform', $requestData);
// JRequest::setVar('jform', $requestData, 'post');
$context = 'com_mentorship.edit.address';
$values = (array) $app->setUserState($context.'.id', $id);
parent::save();
now in the controllerform.php (the parent save function)
array 'id' => string '4' (length=1) 'company_id' => string '1' (length=1) 'table_name' => string 'client' (length=6) 'parent_id' => string '5' (length=1) 'type' => string '1001' (length=4) 'primary_address' => string '0' (length=1) 'address' => string 'Gravendreef' (length=11) 'address_nr' => string '89000111' (length=8) 'zip_code' => string '8888HH' (length=6) 'city' => string 'Den Haag' (length=8) 'phone_number' => string '' (length=0) 'fax_number' => string '' (length=0) 'email' => string '' (length=0) 'published' => string '1' (length=1) 'date_modified' => string '2013-03-19 20:43:42' (length=19)
As you can see the date_modified has the old value.
I also tried
$jInput->input->set('jform', $requestData);But it looks to mee the input->set or input->post->set is not altering the $_POST var.
Do the parent::save function will receive the old values.
$_POST['jform'] = $requestData;
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To post to this group, send an email to joomla-de...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
For more options, visit https://groups.google.com/groups/opt_out.
That would be nice if JInput worked properly to retreive html data.
$jinput = JFactory::getApplication()->input;
$return_value = $jinput->get('html_field', null, 'SAFE_HTML');
http://docs.joomla.org/Retrieving_request_data_using_JInput
So i think i have 2 options, use the deprecated JRequest::setVar until JInput does have a set function to rewrite the $_POST or write $_POST directly myself.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.
To post to this group, send an email to joomla-de...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.
To post to this group, send an email to joomla-de...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.
To post to this group, send an email to joomla-de...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsubscribe@googlegroups.com.
To post to this group, send an email to joomla-de...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
For more options, visit https://groups.google.com/groups/opt_out.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
But back to initial question - why this is not working?
$input = JFactory::getApplication()->input;
$input->post->set('myVar', $myVar);
Then in another class:
$input = JFactory::getApplication()->input;
$myVar = $input->post->get('myVar');
And should we use this instead (not altering post):
$input->set('myVar', $myVar);
$input->get('myVar', $myVar);
Hi AllAs you will all know the JRequest is decrepated in Joomla 2.5. So I am changing lines likeJRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN'));$requestData = JRequest::getVar('jform', array(), 'post', 'array');intoglobal $app;JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));$requestData = $app->input->post->get('jform', array(), 'array');But what is the right one forJRequest::setVar('jform', $requestData, 'post');?Because$app->input->post->set('jform', $requestData);is not working.I use this kind of code in the save function of the backend controller like
public function save(){global $app;JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));$requestData = $app->input->post->get('jform', array(), 'array');
$date = date("Y-m-d H:i:s");
$requestData['date_modify'] = $date;JRequest::setVar('jform', $requestData, 'post'); // this one needs to be changedparent::save();}
On Thursday, 28 March 2013 17:48:54 UTC+10, Dmitry Rekun wrote:But back to initial question - why this is not working?
$input = JFactory::getApplication()->input;
$input->post->set('myVar', $myVar);
Then in another class:
$input = JFactory::getApplication()->input;
$myVar = $input->post->get('myVar');
I'm thinking that should be working. You are accessing the same input variable by reference.
And should we use this instead (not altering post):
$input->set('myVar', $myVar);
$input->get('myVar', $myVar);I've actually been trying to wrap my head around that question for the last few days. There's this strange "double layering" in Input and I'm not sure of why it's been designed that way. It would be much easier to just have Input be independent of the request method or, at least, work that all out at construction time and just allow us to use $input->get all the time (though, I think it makes sense to treat cookies and files differently). Thoughts?Regards,Andrew Eddie
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
On Thursday, 28 March 2013 17:48:54 UTC+10, Dmitry Rekun wrote:But back to initial question - why this is not working?
$input = JFactory::getApplication()->input;
$input->post->set('myVar', $myVar);
Then in another class:
$input = JFactory::getApplication()->input;
$myVar = $input->post->get('myVar');I'm thinking that should be working. You are accessing the same input variable by reference.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.