multiarray and Jinput

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
steelfox
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Tue Jul 28, 2009 3:32 pm

multiarray and Jinput

Post by steelfox » Mon Mar 24, 2014 11:02 am

Hi, I'm trying to build component with sport results, and try to build result form with multiarray post data. Can anybody show me example, step by step how to ?

i have a view with event data (racename) and after click to icon in table row I move to other view with raceresults. In raceresults I need to add a few rows with many columns (row 1 - person
  • , rank[inputbox] - points[inptbox]
    row 2 - person
    • , place[inputbox] - pts[inptbox]
      etc..)
      after every row I'd like to submit data and stay in form to add next.

      I've tried to based on Joomla 3 com_user component with add note functionality, but it allows me to add only 1 row after every action. Can anybody explain me how to do it for multirow input ?
      I understand that I should pick id from race View which will be as hidden column for every row but do not understand how to define and connect other data to form.

      -fields in form and table for raceresults where id and constant race_id are hidden
      [id, race_id, person, rank, points]

      P.S. Of course I've checked all available info like:
      http://docs.joomla.org/Retrieving_reque ... ing_Values
      http://docs.joomla.org/Selecting_data_using_JDatabase
      http://docs.joomla.org/Inserting,_Updat ... _JDatabase
      http://docs.joomla.org/How_to_use_user_state_variables

      Anyway it is not clear explaining where and how to define data. How should I define getItem for multiarray in form ? How to make a form to present all rows from table and row with new data row?

      table for races and table for raceresults are separated

      Maybe just give me a link to component, document etc. where I could analyze how to ?

steelfox
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Tue Jul 28, 2009 3:32 pm

Re: multiarray and Jinput

Post by steelfox » Wed Mar 26, 2014 10:34 am

to be more clear, I've found Jpodium http://www.jpodium.de/component which makes what I expect, but I'd like to adopt this to 3.2. I tried to do it by myself but still have no effect with update of records (add, edit ,save, delete). Maybe someone would like to show how to change this code to be working in 3.2 ? I mean only code responsible for resultsperrace view.

If you believe this is too big effort, maybe you know component with the same functionality for J3.2 in which I could analyze code ?

PS. I found similar solultion on http://www.gwerp.com but this uses different way for keeping data (ref in text field NOT records in separate table)

ahh.. before you ask Detlef Volmer Jpodium author is not interested in component update to J3

steelfox
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Tue Jul 28, 2009 3:32 pm

Re: multiarray and Jinput

Post by steelfox » Thu Mar 27, 2014 1:56 pm

I've found this

Code: Select all

$Data	= JRequest::getVar('jform', array(), 'post', 'array');
but because JRequest::getVar() is deprecated. I'd like to use

Code: Select all

JFactory::getApplication()->input->get()
instead.
how to properly convert it to JInput?

I'm trying something like this but it doesn't work :(

Code: Select all

$jinput = JFactory::getApplication()->input;
$Data	= $jinput->get('jform', array(), 'post', 'array');
doesn't work too.
or

Code: Select all

$jinput = JFactory::getApplication()->input;
$Data	= $jinput->post->get('jform', array(),'array');

steelfox
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Tue Jul 28, 2009 3:32 pm

Re: multiarray and Jinput

Post by steelfox » Fri Mar 28, 2014 11:16 am

Ok, one problem solved:
this phrase

Code: Select all

$Data   = JRequest::getVar('jform', array(), 'post', 'array');
should be changed to

Code: Select all

$jinput = JFactory::getApplication()->input;
$Data   = $jinput->get('jform', array(), 'array');
of course

Code: Select all

$Data   = $jinput->post->get('jform', array(),'array');
is allowed also :o

and one more problem

Code: Select all

$db->query();
must be changed to

Code: Select all

$db->execute();
But it's still not working. So i can publish data but until now cannot edit or add a new row

steelfox
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Tue Jul 28, 2009 3:32 pm

Re: multiarray and Jinput

Post by steelfox » Fri Apr 11, 2014 6:34 am

I've solved problem but have another :).
I cannot get hidden fields thats why I had a problem with form, after change to "readonly=true" everything works ok. But next question.

How get hidden field from form ? I cannot get it when is not presented in form :(


Locked

Return to “Joomla! 3.x Coding”