Updated 073 JCB Fields Type Extended (markdown)

Amigo 2019-10-31 10:33:13 +02:00
parent fa12eebb28
commit 1dd7fd3785

@ -35,23 +35,26 @@ The `getoptions` function or method is requiring this chunk of code. Now instead
[00:08:19](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m19s) [00:08:19](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m19s)
If you don't know what all the field types are that exist in Joomla then a good place to start is to go to Field Types and check out all these and if that is still not clear you can go to this URL. This has a list of all Joomla's field types so you could [00:08:43](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m43s) open that, scroll down and here is a list of all the field type names that you can not use again. It will be conflicting because it will break that name in that form. Do not use names that are not used by Joomla.>>>>>>>> If you don't know what all the field types are that exist in Joomla then a good place to start is to go to Field Types and check out all these and if that is still not clear you can go to this URL. This has a list of all Joomla's field types so you could [00:08:43](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m43s) open that, scroll down and here is a list of all the field type names that you can not use again. It will be conflicting because it will break that name in that form. Do not use names that are not used by Joomla.
**Going back to create a Custom Field.** [00:09:12](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m12s) We could start with Sermon Preacher which is the one we are looking at. So again the name up here is just for the interface for you, it's just that you can see what is the field. You can call this anything. It only falls back to this name if there isn't a label set here, then it will fall back to this name. [00:09:39](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m39s) But the ideal is just set the label. **Going back to create a Custom Field.** [00:09:12](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m12s) We could start with Sermon Preacher which is the one we are looking at. So again the name up here is just for the interface, it's just to see what is the field. You can call this anything. It only falls back to this name if there isn't a label set here, then it will fall back to this name(Follow on video). [00:09:39](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m39s) But the ideal is to just set the label.
The name here is actually the code(See video) This is the type and this is what is going to be unique. The rest is multiple, the same as everything else. The default value because it is dynamic, it is not really practical but it is really going to be whatever you choose to be the ID of this memory. [00:10:11](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m11s) 'Required', 'Read Only', etc. In this area choose what kind of field you would like to create. The name (see video) is actually the code. This is the type and this is what is going to be unique. The rest is multiple, the same as everything else. As the default value is dynamic, it is not really practical but it is really going to be whatever you choose to be the ID of this memory. [00:10:11](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m11s) 'Required', 'Read Only', etc. In this(see video) area choose what kind of field you would like to create.
### The Button Feature ### The Button Feature
[00:10:20](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m20s) [00:10:20](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m20s)
Then the 'button' feature is one of the features that are quite exciting. Let me show you some of that. I was seeing a strange behavior here that the button says 'true' and then when I go to the code I don't see the button code in there. I was wondering what is going on here and then I remembered when JCB detects that [00:10:48](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m48s) there is two Custom Fields with the same type, it only uses one for this(the php for the getOption method) area and for the button. Because one of them is going to be the dominant one. [00:11:12](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m12s) You can decide which one it is, you want to share the field type among multiple Custom Fields. If you want to reuse that field type, you can. You want to make sure that one of them is the one which you know is going to be dominant, the one who decides how things happen. If you change that one the field type updates. Whereas if you change the wrong one it doesn't do anything. So just one of those will be the [00:11:47](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m47s) the dominant one. You can do that by making it the prime PHP and make that 'one'. Here is a little explanation of that. If you want to be sure this field called 'Preachers' should be the dominant and you want to say; I want the buttons to be 'true' if you save and compile, you will get what you expect. That's **another feature of Custom Fields that people are not aware of** but it makes it very useful. Then the 'button' feature is one of the features that are quite exciting. Let me show you some of that. A strange behavior occures here; the button says 'true' but in the code the button code does not appear. I was wondering what is going on here and then I remembered that when JCB detects that [00:10:48](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m48s) there is two Custom Fields with the same type, it only uses one for this(the php for the getOption method) area and for the button because one of them will to be the dominant one. [00:11:12](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m12s) You can decide which one it is and if you want to share the field type among multiple Custom Fields and if you want to reuse that field type, you can. You want to make sure that one of them is the one which you know is going to be dominant, the one who decides how things happen. So if you change that one, the field type gets updated. Whereas if you change the wrong one it doesn't do anything. So just one of those will be the [00:11:47](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m47s) the dominant one. You can do that by making it the prime PHP and make that 1. Next to it is a explanation of that. If you want to be sure this field called 'Preachers' should be the dominant and you want to say; I want the buttons to be 'true' and if you then save and compile, you will get what you expect. That's **another feature of Custom Fields that people are not aware of** but it makes it very useful.
### Get Input(How Button is added) ### Get Input(How Button is added)
[00:12:29](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m29s) [00:12:29](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m29s)
If we now go back to the code, we see a new set of a script called `getinput`. That's how the button gets added. It asks `getAttribute('button')`, it checks if `button` is `true`. If button is `true`, then it already have the parent `HTML` (the whole field is in this HTML). If you have a button and someone clicks on it, you might want them to [00:13:07](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m07s) be redirected back to this page where the field is, once they are done on the other page. This is what it does, it checks if there is a 'Referral'. We are building a return value as well. We come down here and we start to build the button. There is the button being built(See Video). [00:13:44](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m44s) That is to create. This is called preachers, and down here we have a view called 'Preacher' and 'Preachers'. That is the Single View, the Single View name of the place, the field is added. This is the 'Listview'. We are grabbing the field data from the Preacher View, and it's List name is 'Preachers'. It is the table where the data is being captured from. Not the table where you are going to show the field but the table where you are taking the information from.[00:14:55](https://www.youtube.com/watchv=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m55s) If you take it from multiple tables, then you must choose a dominant table. The one that you want to be always available. That's what this is as well as this as you can see. It is usually the case that preachers and preacher values are the same. I decided to give the option to change the table name. If we now go back to the code, we see a new set of a script called `getinput`. That's how the button gets added. It asks `getAttribute('button')`, it checks if `button` is `true`. If button is `true`, then it already have the parent `HTML` (the whole field is in this HTML). If you have a button and someone clicks on it, you might want them to [00:13:07](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m07s) be redirected back to this page where the field is, once they are done on the other page. This is what it does, it checks if there is a 'Referral'. We are building a return value as well.>>>>>>>
We come down here and we start to build the button. There is the button being built(See Video). [00:13:44](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m44s) That is to create. This is called preachers, and down here we have a view called 'Preacher' and 'Preachers'. That is the Single View, the Single View name of the place, the field is added. This is the 'Listview'. We are grabbing the field data from the Preacher View, and it's List name is 'Preachers'. It is the table where the data is being captured from. Not the table where you are going to show the field but the table where you are taking the information from.[00:14:55](https://www.youtube.com/watchv=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m55s) If you take it from multiple tables, then you must choose a dominant table. The one that you want to be always available. That's what this is as well as this as you can see. It is usually the case that preachers and preacher values are the same. I decided to give the option to change the table name.
We will get to these again. Just wanted to [00:15:28](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m28s) show you that if those two(preacher and preachers) line-up, the button name lines up with those two. It checks whether this current user has authority to edit buttons. We can go down and create and edit button. We can also write JavaScript to [00:16:01](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m01s) give that button behavior. When you click change the field, it checks: Is that value? and then it updates. You can check out if this is JavaScript. This one up here is used to generate the create button and it also validates whether this user has create options, [00:16:30](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m30s) and is the user in the admin area. Currently this feature is not available to the site area and it's because of many conventions in the site area, so is custom. It'll probably break this button. We'll have to work at this but this is where we are at. We will get to these again. Just wanted to [00:15:28](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m28s) show you that if those two(preacher and preachers) line-up, the button name lines up with those two. It checks whether this current user has authority to edit buttons. We can go down and create and edit button. We can also write JavaScript to [00:16:01](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m01s) give that button behavior. When you click change the field, it checks: Is that value? and then it updates. You can check out if this is JavaScript. This one up here is used to generate the create button and it also validates whether this user has create options, [00:16:30](https://www.youtube.com/watch?v=91iIAuHZj38&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m30s) and is the user in the admin area. Currently this feature is not available to the site area and it's because of many conventions in the site area, so is custom. It'll probably break this button. We'll have to work at this but this is where we are at.