public function storeans()
{
$user = JFactory::getUser();
$post = JRequest::getVar('post');
}
In the above code, JRequest
is deprecated.
What is the equivalent that can be used in Joomla 3.x?
Joomla Stack Exchange is a question and answer site for Joomla! administrators, users, developers and designers. It only takes a minute to sign up.
Sign up to join this communitypublic function storeans()
{
$user = JFactory::getUser();
$post = JRequest::getVar('post');
}
In the above code, JRequest
is deprecated.
What is the equivalent that can be used in Joomla 3.x?
JRquest has been deprecated in the earlier release of Joomla 3.x
Use JFactory::getApplication()->input
instead.
For getting any variable (say name) from post method use below line of code
JFactory::getApplication()->input->post->get('name');
Firstly, I'll just say that you need to use JInput
. More information on this can be read about here:
https://docs.joomla.org/Retrieving_request_data_using_JInput
So to start off with: you need to call JInput
via the application like so:
$jinput = JFactory::getApplication()->input;
Then, if you wish to get a single value, you can use:
$name = $jinput->get('name');
Or if you wish to get an array of data, let's say from a form with multiple fields, then you can use:
$data = $jinput->post->getArray(array());