Sometimes, you need to add dropdown fields with dynamic values to your website. Creating database table and form for each option is time consuming. To simplify things, we have added the options module in our script.

How to add an option field?

  • Login to the Admin Panel, visit Settings->Options->Option Types and click the Add Option Type button.
  • Give a name to the field, the name must be in lowercase without any space and special characters. You can use underscore instead of space.
  • The Priority field controls the order the Option Types display. Items assigned the same display order will sort alphabetically. The lower value option types will always be displayed on the top.
  • Check the Status checkbox and click the Save button.
  • Use FTP and edit the application/modules/options/language/english/options_lang.php. Add two strings:
    • tab_<OPTION TYPE NAME>: e.g. $lang['tab_services' = 'Services';
    • <OPTION TYPE NAME>: e.g. $lang['services'] = 'Services';

How to add an option?

  • Login to the Admin Panel, visit Settings->Options->Add Option link.
  • Check the Language String? checkbox, if the option is a string from the language file. Keep unchecked, if the option type is a normal English word.
  • Check the Status checkbox to make the option active.
  • Use the Type dropdown field and select the option type created earlier.
  • Give a name to your option.
  • If the option is a child, select parent option.
  • You can also set an image and add a description to your option.
  • Set a priority value to change the display order.
  • Click the Save button to save your option.

How to use an option field?

  • Add a new field with the same name to the database. The field name must be the same to the option type created previously.
  • After adding the field, visit the Developer->Fields->Create Field section.
  • Select a module and give a name to your field. The field name must be the same you created in the database. Follow our fields section for step by step instructions on how to add a new field.
  • Chose selectize as the field type.
  • Use the following in the options field:
    • load: It must be set to options. E.g. load:options
    • module: It must be set to options. E.g. load:options
    • load_url: ajax/options/<OPTION TYPE ID>. Replace the OPTION TYPE ID with the ID of the option created earlier. E.g. if the new option type id is 3, use load_url:ajax/options/3
    • relation_value: Enter the option type id here. E.g. relation_value:3
    • relation_field: Use type_id here. E.g. relation_field:type_id
    • max_items: The maximum number of items a user can select. Default value is 1. E.g. max_items:10
    • no_ajax: Set to 1 to load the options on page load. The default value is 0.
    • params: You can also set a parent/child relationship between fields. Use the params option to set a relationship. E.g. params:relation#subservices, this will load the subservices field with the new options on the value change of this field.
    • Use the following additional parameters in the options field. E.g params:root#services,root_value#1
      • root:#<PARENT FIELD NAME>
      • root_value:#<PARENT OPTION TYPE ID>

    E.g. Parent Field (services)
    E.g. Child Field (subservices)
  • Check the The Options are in the Language String? and The Options are added in detail? checkbox.
  • Click the Save button to save your field.