I face the problem, that I have list formfield, where no values have been set in the xml formfield description. The values for the listfield will be created on runtime via jquery. When I choose a value, the value will be stored in the database, but with new open of the form the value from the database will be loaded, but not shown in the listfield. The listfield stays empty. Is this because of no standard values in the xml formfield description?

  • Yes that is exactly why it is not being set. You would have to pass the value to javascript and update the value in javascript as well. Commented Feb 17, 2015 at 17:57
  • Ok, i've tried to integrate it as new variable derived from php. But in conjunction with Joomlas scriptdeclaration for integrating javascript, iam not able to get access to php variables. Therefor I made a seperate thread: joomla.stackexchange.com/questions/8675/…
    – Perino
    Commented Feb 18, 2015 at 7:58

1 Answer 1


You should create a field element on the fly if the data for that element exists. For example:

if (isset($data->someField) && !empty($data->someField))
    $element = new SimpleXMLElement(


You can place it in preprocessForm() method or in getForm() method of your model.

  • Thanks Dmitry for your input. To be more concret, I have two listfields which are in relations. The first listfield is responsible to offer different countries. The second listfield, which is in relation to the first listfield, should offer the states for the selected country of the first listfield. Which method would be best, to achieve that goal?
    – Perino
    Commented Feb 18, 2015 at 9:16
  • Is there a reason you can't have all the data in the XML and use "showon" linked to the country select to show one of state/region listfields? So you'd have a separate listfield defined for every country that needs the second field, but only one would be shown. Commented Feb 18, 2015 at 9:40
  • @Dmitry: how do you handle changes of the select options in the listfield1 while the customer fills out the form? This question is also to Ville Niemi!
    – Perino
    Commented Feb 18, 2015 at 14:02
  • With JS help. @VilleNiemi method also is useful. Commented Feb 18, 2015 at 16:00
  • I know JS functions while form element changes. But do you mean that I have to go with Ajax?
    – Perino
    Commented Feb 22, 2015 at 7:07

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.