4

As we know we can retrieve values of all the fields if they have names like name="jform[something]" and we can use the code:

$jinput = JFactory::getApplication()->input;
$formData = new JRegistry($jinput->get('jform', '', 'array'));

But is there some way to do the same if we have form with some name for example <form name="myForm"> and fields with names like name="something" i.e. without jform[] ?

Thanks in advance

Joomla 3.5.1

5

Yes, you can get the form values without jform. Following is the approach:

  • $data = $jinput->post : returns all post data
  • $something = $jinput->post->get('something', 'default_value', 'filter');

Refer here:

https://docs.joomla.org/Retrieving_request_data_using_JInput#Getting_Values_from_a_Specific_Super_Global

  • $data = $jinput->post->getArray() : this is the preferred method for you as it will return only the form fields with and without jform and not the entire post values.

Hope this helps

  • Thanks. $data = $jinput->post->getArray() works only if I wrap it in new JRegistry(). – stckvrw Apr 11 '16 at 8:24
  • for this, you will have to show us the code in your question what are you doing properly. For input values as well just show us the html form which is being passed and in controller how you are parsing the data. It will help us to help you. just add the code in your question – Liz. Apr 11 '16 at 8:43
  • it's ok. I am glad it helped you :) – Liz. Apr 11 '16 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.