3

I have a form with the dynamically generated XML and by dynamically, it was programmatically created during getForm function. I want to save the value I selected as a key:value pair to be stored in a table column:

<field name ="frequency" type="list"
    label="Frequency"
        description="Frequency of sending report subscribed."
        option_on ="Yes"
        option_off ="Yes"
        multiple="true"
>

Now it enables multiple selection, but when I save the form, the values I selected did not reflect.

I have this as reference:

https://stackoverflow.com/questions/2407284/how-to-get-multiple-selected-values-of-select-box-in-php

But my objective is to save the selected values.

enter image description here What could be wrong?

The image above displays the custom field I created. However, those that I have selected "one" and "three" are not saved in the database.

3
  • I updated the question joomla.stackexchange.com/questions/5480/… . This is how i did it, with creating a new custom field as a multiselect list, hope it help you.
    – IseNgaRt
    Dec 16, 2014 at 8:24
  • Could you give more code. The snippet lacks both the options tags and the closing field tag. Or I am misunderstanding the question totally? (Not entirely unlikely...) Dec 16, 2014 at 8:38
  • I just posted the code to show that I set the input field to multiple @VilleNiemi I don't intend to post the entire field Dec 16, 2014 at 8:41

1 Answer 1

2

I was able to resolve this issue with the ff. code:

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

I found out that I do not need to check the field if it is an array or not, I have created an blank array

$fils[$new_filter['name']] = $mydata[$new_filter['name']];

from the code above, this is the interpretation:

$fils['frequency'] = $mydata['frequency']

the variable $mydata['frequency'] automatically contains the multiple values I selected from the dropdown which has an attribute multiple = "true" in the XML file.

Your Answer

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

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