Updated 008 Advanced Fields (markdown)

Amigo 2019-05-31 09:46:51 +02:00
parent 93eccf736b
commit 0a8f3a1a8d

@ -10,24 +10,28 @@ Then I just start the options array, which you going to return. The first thing
Now there is a field type called 'file list'. The reason why I didn't use file list is because file list has a static directory to where [00:03:44](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m44s) you need to add the files, so that you can view them. We want it to be able to rename the folder for the files, for the media, to anything and then have it update itself automatically. That is why we then created a custom field where we extended the list type, and let me just refreshed this to get that detail back. So we chose a custom field and then we just extend the list type, and we don't want it to add 'new button' because it won't work, it will just break. We are allowing them to select multiple. Now since we are using multiple we need to go back and make sure that we are storing it as a 'JSON'. So the 'JSON' is when you have 'multiple' or 'arrays', or any kind of arrays in a value, that needs to be stored as a 'JSON'. [00:04:48](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m48s) The component builder itself will check if the multiple selection is true, it will automatically store it in a 'JSON' object even if you forget to select 'JSON'. There are things in place to ensure that the system behaves as expected.
**How to Create a Sermon Preacher Custom Field**
How to create a sermon preacher custom field. Basically it's a preacher custom field. It is going to show a list of preachers. But is going to display the preachers that are set up in the preacher list view. So let's open that 'Sermon Preacher'. The convention [00:05:52](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m52s) is that you should call the type: preachers, that is the list view name. But you have to call the name you should use the same as the editing name which is preacher without the 's'. If you go back to your admin views you would use this name as the name of the field, but you have to use that name as the type. Because now you are creating a custom type, and the logic behind it, it is going to show a list of preachers but you have to select just one preacher. You can use any label you like, whatever is descriptive enough for your user to understand. There is a place for adding a description. Then in 'XLM field definition' we set multiple to false.They should only be able to select one preacher at a time. At 'Default 0' are all basically left to their default values and [00:06:56](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m56s) 'extending list', is the most common custom field that we have. If you want to receive a list of custom fields that is available, you can go up here to 'extend' and see that list, radio and check boxes are available. I think I should update that to also say users. User is also a user option to extend users. If you want to see what is available then look at that name 'Jformfield' and go to component builder. Go to the back end of component builder, that would be: 'administrator', 'components', 'component builder'. Then go to compiler, that's a folder, then go to Joomla 3, which is the current version we are targeting.
**Sermon Preacher Custom Field**
Let's look at how to create a sermon preacher custom field. So basically it's a preacher custom field. So what is this field going to do? It is going to show a list of preachers. But is going to display the preachers that are set up in the preacher list view. So let's open that(sermonpreacher). The convention [00:05:52](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m52s) is that you would call the type: preachers, that's the list view name. But you'd called the name you would use the same as the editing name which is preacher without the s. If you go back to your admin views you would use this name as the name of the field, but you would use that name as the type. Because you now creating a custom type, and the logic behind it, it's going to show a list of preachers but you going to select just one preacher. That's just the logic. The label you can really put whatever you like, whatever is descriptive enough for your user to understand. And then there's a place for adding a description. Then here we are set multiple to false. We want them to only be able to select one preacher at a time. 'Default 0' these are all basically left to their default values and [00:06:56](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m56s) extending list, is the most common custom field that we have. If you want to receive a list of custom fields that is available, you can go up here to extend and you see that list, radio and check boxes are available. I think I should update that to also say users. User is also a user option to extend users. If you want to see what is available then look at that name 'Jformfield' and go to component builder. Go to the back end of component builder, that would be: 'administrator', 'components', 'component builder'. Then go to compiler, that's a folder, then go to Joomla 3, which is the current version we are targeting.
**Jform in Component Builder**
Then search for that Jform. There's it is Jform. [00:08:00](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m00s) Ones that are available to extend let's see it's the user, Jform field user, it must be Jform field. So JForm field user, Jform field radio, Jform field list, Jform field checkboxes. This also means if there is a form field you want to extend that doesn't exist already in our advanced seminar, we will show you how to add your own form fields here. There is basically two places you will need to change. I wish I could tell you now one of them would be to add the field and update it accordingly. And the other one would be to add it in a few places in the code. And also in a Json file called settings there. Those are some of the things we will deal with in advanced adaptation of component builder. [00:09:04](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m04s)
Then search for that Jform. [00:08:00](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m00s) The ones that are available to extend is 'user', 'Jform field', JForm field user, Jform field radio, Jform field list, Jform field checkboxes. This also means if there is a form field you want to extend that doesn't exist already in our advanced seminar, we will show you how to add your own form fields here. There is basically two places you will need to change. I wish I could tell you now one of them would be to add the field and update it accordingly. And the other one would be to add it in a few places in the code. And also in a Json file called settings there. Those are some of the things we will deal with in advanced adaptation of component builder [00:09:04](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m04s) We will still set up that series very soon it's not finished yet though.
**Extending List in Custom Field**
We will still set up that series very soon it's not finished yet though. Getting back to extending a list field, you simply add there list. Then there's also a few conventions. One of them being that if you are going to be targeting, like this example, we are targeting the preachers. You will be using the preacher table as the table that is being targeted. The question to ask is: Where is the data going to be found? That is the table that needs to be added. In which component is it going to be found? That is what's need to be added by component. Now the reason why we have this ### component### here, because it's a placeholder which component builder will replace with the components code name [00:10:08](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m08s) once it's built. It's a feature we added because some times we want to rename components. If you had statically added the actual component name there, and in every field go and update that name, and in every view go and update that name. Every where you actually statically added the components name, you will need to update it.
Getting back to extending a list field, you simply add there list. Then there's also a few conventions. One of them being that if you are going to be targeting, like this example, we are targeting the preachers. You will be using the preacher table as the table that is being targeted. The question to ask is: Where is the data going to be found? That is the table that needs to be added. In which component is it going to be found? That is what's need to be added by component. Now the reason why we have this ### component### here, because it's a placeholder which component builder will replace with the components code name [00:10:08](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m08s) once it's built. It's a feature we added because some times we want to rename components. If you had statically added the actual component name there, and in every field go and update that name, and in every view go and update that name. Every where you actually statically added the components name, you will need to update it.
To explain to you exactly what the system is doing, I can go to components, open sermon distributor. Take the 'Name in code', like that(sermondistributor), copy, and see that it's lowercase c ,if it was a uppercase like that(C), it mean it would mean that you have to place the component [00:11:12](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m12s) name as well with an uppercase. So we would just do a lowercase s. That is actually what the system is doing. It actually is just replacing these place holders with the actual component name on the fly. Using the placeholders saves you time in the long run. From making changes everywhere, if you make a change to components name. Which is quite normal to do very often you start with the component and you think of calling it something and later realized that name is actually been used in the Joomla repository, and you need to choose another name. And to do that is going to affect the whole component and so we added this placeholder structure which should make the data less painful at least.