Skip to content
  1. Extras
  2. MiniShop3
  3. Manager cookbooks
  4. Extra fields

Extra fields cookbook

An extra field adds a column to the model table and a widget in the Vue form. Full parameter reference: Extra fields.

Goal

Pick a model, key, and xtype. After the migration runs, the field appears in the manager and (for msProductData) may be available in CSV import.

When to use

TaskExtra field
New “wholesale price” column on a productyes
Manager comment on an orderyes
Move price to another section without a new columnno → model fields
Reorder fields on the product “Data” tabno → product fields

Models (class)

In the UI and in POST, use the fully qualified class name:

UI labelclass
msProductDataMiniShop3\Model\msProductData
msOrderMiniShop3\Model\msOrder
msOrderAddressMiniShop3\Model\msOrderAddress
msVendorMiniShop3\Model\msVendor
msCategoryMiniShop3\Model\msCategory

For orders, see the end-to-end example.

xtypes in 1.13

xtypePurpose
textfieldString
numberfieldNumber
textareaMultiline text
xcheckboxYes/no
ms3-combo-selectSelect from select_options
ms3-repeaterRow table (JSON)
ms3-key-valueKey → value pairs (JSON)
ms3-combo-vendorVendor picker
ms3-combo-autocompleteAPI autocomplete
ms3-combo-optionsProduct option

Rich text editor and date xtypes are not in the extra-fields UI in 1.13. Track issue #610 and #612.

Case: select on a product

  1. Utilities → Extra fields → class msProductData.
  2. Key supply_type, xtype ms3-combo-select.
  3. select_options:
json
[
  ["stock", "In stock"],
  ["on_request", "Pre-order"]
]

Set dbtype varchar and phptype string.

For msProductData the package also creates a row in ms3_product_fields so the field shows on the “Data” tab.

Case: repeater

  1. xtype ms3-repeater, dbtype/phptype json.
  2. repeater_config:
json
{
  "columns": [
    { "key": "name", "label": "Name" },
    { "key": "qty", "label": "Qty", "type": "number" }
  ],
  "minRows": 0,
  "maxRows": 50,
  "sortable": true,
  "rankField": "rank"
}

Repeaters are not included in CSV import.

Case: key-value

  1. xtype ms3-key-value, dbtype/phptype json.
  2. key_value_config:
json
{
  "mode": "fixed",
  "keys": [
    { "key": "width", "label": "Width", "valueType": "number", "required": false },
    { "key": "material", "label": "Material", "valueType": "string", "required": true }
  ]
}

mode: free allows adding pairs in the form.

Order form output

After creating a field for MiniShop3\Model\msOrder, open an order card. Additional order fields is built from GET /api/mgr/extra-fields and OrderExtraFieldsSection.vue.

Save sends the field key at the top level of PUT /api/mgr/orders/{id} (see example).

API appendix

MethodPathPermission
GET/api/mgr/extra-fields?class={class}mssetting_save
GET/api/mgr/extra-fields/{id}mssetting_save
POST/api/mgr/extra-fieldsmssetting_save
PUT/api/mgr/extra-fields/{id}mssetting_save
DELETE/api/mgr/extra-fields/{id}mssetting_save

POST/DELETE triggers a Phinx migration. Check the MODX log if creation fails.

Troubleshooting

SymptomAction
“Column already exists”Column or duplicate key already present
Field missing on product cardFor msProductData, check ms3_product_fields and visible. See product fields cookbook
Empty order section with active=1Form uses class=msOrder. DB: MiniShop3\Model\msOrder. API filters by exact match
Repeater/key-value won't saveJSON schema in config, dbtype must be json
403mssetting_save

Reference: extra-fields.