Search code examples
formsmodxmodx-evolution

MODx eForm: populating hidden fields


My goal is, that eForm populates hidden fields with data my script receives from a database. I was able to successfully populate all visible input fields with my function called through &eFormOnBeforeFormParse. When I want to populate hidden fields, it does not work. They are empty or MODx/eForm complains that the form was tampered with.

I could just throw the data in regular input fields and hide them with css, but is there a way to do this appropriately with type="hidden" fields?


Solution

  • Use the eform attribute to prevent validation of hidden fields:

    <input type="hidden" name="calculatedField" value="" eform="::0::" />
    

    More info here: http://wiki.modxcms.com/index.php/EForm#Hidden_fields.2C_select_boxes.2C_radio_options_and_checkbox_fields