2

I am using the code below for getting form values:

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

However, when I use json_encode, it encodes all the form fields I use. How do I select fields in the form from a specific fieldset? I have 2 fieldsets in my Form, the original one and the other fieldset named 'reportFilters'. I can only use the getFieldset in my View Class.

3

When using the above command to retrieve server request data, the form fields are organized in a key/value array. Which fieldset is irrelevant to retrieving the data from the array, simply use the form field name given in the XML form definition file. So, if you had a field called 'first_name' you would access like so regardless of which fieldset:

$data = JFactory::getApplication()->input->get('jform', array(), 'array');
$data['first_name']

Hope that helps.

  • is there any way for the generated form together with my custom fields be retrieved to the model? – Break the Law Dec 12 '14 at 5:56
1

Since my custom fields were all from the database, I had a workaround with this issue, and that is to create a new associative array, and load the custom fields from the database and then assign values of the custom fields coming from what I have got from this code.

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

The only thing that made this difficult is I was supposed to create the form as dynamic as possible.

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.