Skip to main content
3 of 6
deleted 21 characters in 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');

It works if all the fields names like name="jform[someName]" and I get the result like

{"someName1":"someValue1","someName2":"someValue2"}

Can I achieve the same result but only with name="someName" without jfrom[]?

Thanks in advance

Joomla 3.5.1

stckvrw
  • 891
  • 9
  • 24