Custom fields – creating groups of custom fields
Now just suppose you want more than one custom field type on a whole range of products. You guessed it, you need to create a group or a parent. The existing custom fields can then be made into children of the parent. Clearly this is a slightly different order from how human parents get their children. We could think of the existing custom fields as orphans and the parent we will soon create as an adoptive parent. Yes that works better.
Getting ready
Choose the custom fields you are going to have adopted, by your soon to be created parent.
How to do it...
We are going to group together a couple of the custom fields from earlier recipes and add them to the Joomla! the Movie product:
- Select the Products menu and then the Custom Fields link. Click on the New link and configure just the Title and the Type fields.
- Title can be whatever will remind you what it is and Type must be Parent. See the following screenshot for clarification:
- Save your new parent custom field, and from the list of your custom fields, click the first custom field you want to make a child of the parent. This is nice and easy.
- Click the Parent dropdown and choose your newly created parent. Click on Save. It is now adopted. Repeat this last step for any others that you want to become a child of the parent.
Adding the parent custom field to a product:
- Select the product to add the parent custom field to from the list of your products. Click on the Custom Fields tab.
- Scroll down and select your parent custom field from the dropdown as shown in the following screenshot:
The following screenshot displays what you will see:
Configure the child custom fields the same way you did when they were not children and were presented on their own and click on Save.
How it works...
By combining multiple custom fields, by adding them to a parent to create a group, we can have lots of useful groups to suit all the product types in our catalog.
For exactly how to create and then configure the two children of the parent that have been added, please see the previous recipes.
See also
- The Custom fields – adding customizable product text and charging per letter recipe
- The Custom fields – customizing products with versions and charging different prices for them recipe