1. "Fabrik 4" helpers needed!

    You are invited to join other community members active in coding, maintaining and improving Fabrik. Please visit https://fabrik.help for more information!
    Dismiss Notice

Set element defaults from URL

Dec 27, 2013
Set element defaults from URL
  • By defining a custom link for an Add button (to add a new record), you can alter one or more elements' default values by altering the URL's querystring.

    So presuming that your form's URL is:
    Code (Text):

    http://site.com/index.php?option=com_fabrik&view=form&formid=1
     
    and you have an element whose full name is 'mydata___name', to fill that element with the value 'Rob' you can alter the query string to be:
    Code (Text):

    http://site.com/index.php?option=com_fabrik&view=form&formid=1&mydata___name=Rob
     
    Note: For element's such as checkboxes, dropdowns or radio buttons, the value supplied in the querystring must be the value that is stored in the database and not the attached label. So say we have a checkbox whose full name is 'mydata_ok' and which has a single sub-option value = 1, label 'yes', our URL would be
    Code (Text):

    http://site.com/index.php?option=com_fabrik&view=form&formid=1&mydata___ok=1
     
ontarget and malucena like this.