• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Autofill form plugin

  • Views Views: 26,656
  • Last updated Last updated:

Navigation

         Form Article Plugin Tutorial
      Autofill form plugin
      Clone form plugin
      Comment form plugin
      Email form plugin
      EXIF form plugin
      FTP form plugin
      J2store form plugin
      Kunena form plugin
      Limit form plugin
      Logs form plugin
      Mailchimp form plugin
      Paginate form plugin
      Paypal form plugin
      PHP form plugin
      Pingdotfm form plugin
      Receipt form plugin
      Redirect form plugin
      REST form plugin
      Slack form plugin (+)
      SMS form plugin
      Twitter form plugin
      Upsert form plugin
      VBforum form plugin
      Create a Search Form
      Accordion Form Groups
  • The autofill plugin allows you to fill in fields based on a look up on a different list.

    Use appropriate field types. E.g. don't "fill" a calc element, it won't store the value but calculate your code.

    The data entered from the list is NOT dynamic, so if your form observers a user list, and you create a record autofilled in from the user 'John', and then later on you change that user's name to 'John Smith' then this form's record will still contain the value 'John'

    If you are looking for dynamic links between data you should be using List Joins

    autofill-data.png



    • Connection - The fabrik connection that contains the lookup list
    • List- the Fabrik list that contains the data to insert into the form's Elements. This will usually be a different list, but it can be the same one your form is on, allowing you to select other row data from the same list to either base a new row on, or edit (see "Edit original Record" below).
    • Lookup field - A field in the lookup list. The autofill will return a record from the lookup list where this fields value matches the observed field's value.
      If left empty the plugin presumes that the record to use has a primary key value the same as the 'Field to observes' current value
    • Field to observe - the field which should contain the primary key of the list specified in the 'List' dropdown. If no trigger element specified, the autofill lookup will be performed when this element blurs or changes
    • Map data - a JSON object, where the key value is the lookup table's full element name, and the value a full element name of one of the current form's Elements. So in the image, data will be taken from 'countries___label' and placed in 'elementtest___name'
    autofill-options.png


    • Trigger - If selected, this should be a Button element, when clicked the autofill lookup will occur
    • Edit original record - If set to yes, then when the auto fill lookup is performed and a match found the form's row id is changed to that of the matched record, meaning that you will edit the original record. NOTE - you should only ever set this to Yes if the list you are using to take the autofill data from is the same list your form is built on.
    • confirm - When the trigger element blurs or is clicked, do you want a confirmation box to appear asking the user if they want the fields to be auto-filled
    • Autofill on load - If creating a new record, and this option is set to yes then the autofill will be performed when the form is loaded. In addition trigger events will still be used

    Advanced map features​

    To fill fullname with both first name and last name from the lookup list:
    Code:

    {"{h1qku_comprofiler___firstname} {h1qku_comprofiler___lastname}":"form_plugin_autofill___fullname"}

    In case of multiple fields to be updated you could add several mappings so that a multiple update could be perform in a single call. Just add all the mappings in the following form :
    Code:

    {"table_origin":"table_dest","table_origin2":"table_dest2","table_origin3":"table_dest3"}

    Javascript Events​

    The plugin fires two events, fabrik.form.autofill.update.start and .end. The start event can be used to modify data before inserting it into the form. For example, if you are autofilling a field which has number formatting applied, you will need to manually format the data, because the string you get from autofill will not have the field's formatting applied. So you would create a ./components/com_fabrik/js/form_X.js file (where X is the numeric ID of your form), and do this:

    Code:

    requirejs(['fab/fabrik'], function() {
    Fabrik.addEvent('fabrik.form.autofill.update.start', function(form, data) {
    data.table___element = Number(data.table___element).toLocaleString("es-ES", {minimumFractionDigits: 2});
    data.table___element_raw = data.table___element;
    });
    });

    Modify the table___element names to suite, and use the locale string you need.
Back
Top