This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hi there. I'm developing an extending plugin for JKShop to add the possibility to add Properties and Options to the Products. It's all done except I now have to extend the backend form to also show the options. This is how the product_json (jsonable) looks like:
[{
"product_id":1,
"quantity":3,
"options":{
"size":"XX-large",
"name":"Hamberg",
"number":"5"
},
"total_price_without_tax":1437.6,
"total_tax":359.4,
"total_price":1797
}]
Notice that it's possible though my plugin to add any property and option you want to. In this case I've added three different properties: size, name and number, where size have a couple of different options to it. The other two properties are just textfields. So the solution must work with any type of properties, no hard coding of names.
This is however represented in the backend form with this:
products_json:
type: repeater
form:
fields:
product_id:
label: 'Product id'
type: dropdown
options: getProductOptions
quantity:
label: Quantity
type: number
total_price_without_tax:
label: 'Price without tax'
type: number
total_tax:
label: 'Total tax'
type: number
total_price:
label: 'Total price'
type: number
So... now to the question. If i try adding another repeater like this, inside the other:
options:
label: Options
type: repeater
form:
fields:
type: text
The tree looks okay, and the number of fields are the same as the number of options, but the text fields are empty, no label and if i update the form, the options are overwritten with nada. What I really want to be able to do is this:
options:
label: Options
type: repeater
form:
fields:
label: key
type: text
valueFrom: value
But if I try that it asks me for the key and value partials... So... To my question: How to do this?
The best solution would be to list the options like separate fields. But even showing all the options as a json-string in a textfield would work for now. As long as the json-string in the database gets stored correctly
Last updated
If you want to try for yourself you can find the plugin here: https://github.com/Hambern/properties
1-2 of 2