Updated 5. Field Types (markdown)

Joseph Geller
2018-11-26 18:31:47 -06:00
parent 3f03aca6c5
commit 0498bacd1b

@@ -45,18 +45,21 @@ We have not implemented all the attributes that can be targeted though. You migh
Here is a complete list of [form fields](https://docs.joomla.org/Standard_form_field_types). There is a column which is called type and a value for checkbox and it must be set to not adjustable because that is the way it is expected. If you don't understand any of this information that I'm showing you here then a place to go to is to open the form fields and you'll see a whole list of form fields. These are the same for the fields you just saw in our component. If I was to take the checkbox in the list of check boxes and open that you'd see that they give you a list of those fields. Next type name and JCB tells you what is mandatory and what is optional and basically we are just mapping that data into this form.
### Format of XML String in Form Used by Joomla! to Build the Form
If we want to add another attribute, click on the + and it creates a new field and we can add the name for the value then tweak some of the switches requiring synchronization and provide some other information. The information block here is for you to use. We put information there when when you use this field type so you are reminded what this specific attribute is for. I added this information by copying it from Joomla!'s website and placed it in the provided area where I felt there could be more information. I added some custom text to it indicating what these values will do. They will create an XML string like that in your form which Joomla! then uses to build those forms [14:05](https://youtu.be/OhLzvThDXls?list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=14m05s) **XML string format for joomla** _Reusable field types_. We first setup a field type by telling you which input values you can use for the specific field type which is indicated using the status check boxes. Save this and later you can reuse this field type when you start creating fields. Close this check box and go to the text field. [14:45](https://youtu.be/OhLzvThDXls?list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=14m45s) **Text field type example** _Fields within Text field type_. You'll see that there is a list of the fields that used the text field as its type. You can open one of these fields and at the bottom you see very something very similar if I was to go back to the text field on Joomla!'s website.
+ [15:15](https://youtu.be/OhLzvThDXls?list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=15m15s) **Joomla XML example Text Field** _XML example_
You see that it shows you examples of how that XML line should look in the field area where you created the field. The field has a name which is just for the system. The other field used here is the one that is important. That should be descriptive text which is the field label. This is what displays when you add it to your view. This is what we use to identify it. I am explaining how to add it to the view in more detail. The data type and other things were also shown to explain them.
### Optional and Mandatory Values for Field Type Member On Change
We won't go into more depth about what a field is and how to build one. We have looked at a few field types and shown the effects of changes I feel that you would probably make using those types. This is the detail that was in field type Member On Change and it tells you what is mandatory and what is optional because I placed it in the description. Click close to go back to that field type and then click on property. I added optional and mandatory to the description. It could have been done from here so if not true then it's not necessary to add it there. But you know the settings here are used when we compile the component where as this here is used for you to know what this field attribute is. Maybe as we continue to develop this component I might change it. I wouldn't make any changes that affects anything that already exists this dramatically.
+ [17:43](https://youtu.be/OhLzvThDXls?list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=17m43s) **XML string within compilier** _How XML string is build and compilied within component builder_.
The way the compiler works it is doesn't really grab the string and just put it into the XML. In fact, if I show you how a string looks that the compiler is built, the assessment type, you see that it is completely reformatted. The label is turned into a translatable string. It's been done done with the description also. It also tells you where in the compiler. We'll still look at that because this might show sometimes and you can use apply a JCB tweak to your component so it doesn't show it. But it tells you which line in the compiler it was built in and also in what file which is very nice. I think those of you that are developers will appreciate this feature tremendously. It also tells you the field type and you can see it as we scroll through it. You can see that Component Builder really goes way out of its way to reconstruct that field. It is not using this directly. In fact, it grabs that part and that area to determine if it is a text field. So, it is dependent on that part which is up to name and that part there. The opening exclamation and the closing one and the value in between them is what is used. If you prefer or by accident drop off this or that it will still work perfectly.
### How Demo Data Populates New Field From Values Added During Field Type Creation
These are really the only things needed to understand using field types. Eventually these may become input fields in one big text area that leaves us with a lot of room and freedom to adjust easily without major complications. In any case if you start a new field, which we'll look at later, it populates this with the demo data and the demo data is actually values that you added when you created the field type. You see in the demo it is this value from the example that is placed here. It's from these values that the region is in if you create a new text field. It grabs these values as the values which you can then adjust to suit your purpose. If you you know implementation for that specific field at that moment and if you leave it blank it will also build it without any value between those two estimation marks that is looking at field types.
Most field types have been set up for you and you hardly ever would need to come here except for a deeper understanding of how field types work and how Joomla! and JCB implement them. You do not need to change things unless you wish to. You may be interested in my next tutorial on how to use field types in fields.