Skip to main content
2 of 6
edited body
stckvrw
  • 891
  • 9
  • 24

How to get values of all the filled fields of entire form with JInput

I know that we can get value of some specific field by using:

$input = JFactory::getApplication()->input;
$value = $input->get('someName', '', 'post');

and set it as the body of letter by using:

$mailer = JFactory::getMailer();
...
$mailer->setBody($value);

But if I have the form like:

<form name="myForm">
    <input type="radio" name="radioName" value="Value1">
    <input type="radio" name="radioName" value="Value2">
    <input type="radio" name="radioName" value="Value3">
    <input type="checkbox" name="checkboxName1" value="Value4">
    <input type="checkbox" name="checkboxName2" value="Value5">
    <input type="text" name="textName">
    <input type="submit" name="submitName" value="Send">
</form>

then how can I get values of all the filled fields of the form as an array?

I found the code:

$formData = $input->get('jform', '', 'array');

and I see it's being used for fields with name="jform[someName]" but it seems doesn't work for me too or I can't understand how to use it properly. Can I avoid names like name="jform[someName]" for my purpose and just using name="someName"?

Thanks in advance

Joomla 3.5.1

stckvrw
  • 891
  • 9
  • 24