2

I am trying to load a array of form fields as below.

grade.xml

<field  name="gralev_code[]" 
  type="text" 
  class="width20"
  label="JSCH_GRALEV_CODE"
/>

default.php

$this->form->getInput('gralev_code[]')
$this->form->getInput('gralev_code[]')
$this->form->getInput('gralev_code[]')

The above shows 3 text fields in the form however the values are not received in the model.

Not sure whether this is achievable or not?

2 Answers 2

4

I manged to get a solution as below.

<field  name="gralev_code][]" 
  type="text" 
  class="width20"
  label="JSCH_GRALEV_CODE"
/>

in model.php

$formdata = $this->_jinput->get('jform', '', 'array');
$vals = $formdata['gralev_code'];

On higher Joomla versions from 3.4 use the below

gralev_code][
2
  • 1
    On Joomla 3.4.5 you have to write name="gralev_code][" .
    – Laoneo
    Commented Nov 12, 2015 at 14:38
  • @Laoneo I have tried this, but it doesn't save the plugin's params. Commented May 11, 2016 at 11:55
0

You can use wrapper, unfortunately you can't fill non unique array keys. Then catch data by "fields" name ...->input->get('jform')

$jform['keyname']['a1']

<fields name="keyname"> 
    <field  name="gralev_code[a1]" 
        type="text" 
        label="JSCH_GRALEV_CODE"/>
 <fields>
1
  • Please do your best to use proper English (you instead of u), format your inline code expressions by wrapping in backticks, and try to keep code indentation to a minimum for less horizontal scrolling. When you produce excellent posts, then no one needs to touch your work to bring up the quality of the delivery. Commented Oct 1, 2018 at 22:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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