Get dynamic mail fields / data through JInput in Joomla

Basically, as this question describes, I need to get the "POST" data in Joomla 2.5 / 3.xx, and I want it through JInput (new talk about the city).

Now everything is fine and dandy, until my additional requirements require that these fields / data be dynamic, i.e. It (fields) is intended to change depending on the circumstances, I donโ€™t need to know what the fields will be, I know how to do it in the base php, but this is not the case with JInput, so thatโ€™s how I do it ...

0
source share
4 answers

JInput does not offer such a function; so you have to use $ _POST.

You can get around this if you can have input in the form of an array (and use JInput::getArray() ) or a json-encoded object (you use json_decode(JInput::getString()) )

The latter is very effective, I have used it with success in many projects.

+2
source

Well, I know that some time has passed since this was asked, but today I ran into a problem and found a solution for Joomla for POST forms.

 $input = JFactory::getApplication()->input; $fieldname = $input->post->get('fieldname'); 

This is essentially the same as using $fieldname = $_POST['fieldname']; , except that you get the additional benefit of staying in the Joomla API.

+3
source

try it

  $post = JFactory::getApplication()->input->post; 
+1
source

Joomla3 offers two functions:

JInputJSON (extends Jinput with the getRaw () method)

JResponseJson (convert and return data as JSON)

Request data:

 var jsonString = '{"test":"1"}'; var data = { ajaxrequest : jsonString } 

Joomla:

 $jinput = JFactory::getApplication()->input; $json = $jinput->getRaw('ajaxrequest'); // returns {\"test\":\"1\"} $data = json_decode($json); // json decode, returns data object // do stuff.. echo new JResponseJson($response); 
0
source

Source: https://habr.com/ru/post/944432/


All Articles