How to add custom fields
Custom field feature introduction
Solidres custom field feature in version 0.1.x uses a Joomla’s plugin to add custom field definition into a targeted form. Currently, in Solidres, custom field feature is used for Reservation Asset and Room Type (you can check it by going to edit a Reservation Asset or Room Type and click on tab “Custom fields” to see the current implemented custom fields)
How to add a new custom fields
To add a new custom field for Reservation Asset, open your_joomla_installation_folder/plugins/extension/solidres/fields/reservationasset.xml
To add a new custom field for Room Type, open your_joomla_installation_folder/plugins/extension/solidres/fields/roomtype.xml
I will make an example of how to add a new custom field to show information about dining in the section “Facilities”
First, we need to open “your_joomla_installation_folder/plugins/extension/solidres/fields/reservationasset.xml” and define a new custom field in an XML format, this is where we need to add a new tag
The new tag when added will be looked like the below screenshot.
A field tag contains the following attributes:
- name: a unique name, it is used inside the code
- type: type of extra field, for example, text, text area, list
- rows & cols: these attributes ảeonly used by text area type
- id: a unique id that will be inserted into the extra field HTML
- class: CSS class
- label: the field label
- description: the field description text, will be used for tooltip
- labelclass: CSS class of form field label
So now you have finished adding the definition for a new extra field, now we need define some language string for the new custom field by opening this file /administrator/components/com_solidres/language/en-GB/en-GB.com_solidres.ini and add the following lines into the end of this file:SR_PLG_EXT_RESERVATION_ASSET_FIELD_FACILITIES_DINING_LABEL=”Dining” SR_PLG_EXT_RESERVATION_ASSET_FIELD_FACILITIES_DINING_MESSAGE=”Dining” SR_PLG_EXT_RESERVATION_ASSET_FIELD_FACILITIES_DINING_DESC=”Enter some information about your dining that you want to offer to the client”
Now you can go to your reservation asset in the back end and click on the tab “Custom field” to check if your new custom field is added correctly:
Enter some text into your new custom field to.
How to show custom fields in the front-end
Open file /components/com_solidres/views/reservationasset/tmpl/default_information.php and add the following code like below screenshot.
And open file /components/com_solidres/language/en-GB/en-GB.com_solidres.ini and add the following line into the end of this file.SR_CUSTOMFIELD_DINING="Dining"
Then the new custom field will be displayed in the front end of your reservation asset
How to delete an existing custom fields
Just delete the custom field definition in XML file then edit your reservation asset and click save.