Updated 059 Adding none database fields to an admin view (markdown)

Amigo 2019-09-25 17:16:23 +02:00
parent e7a0dcf666
commit d2b609d14a

@ -5,16 +5,19 @@
[00:00:00](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m00s)
(Click on these time links to see Youtube video)
We've added a new function to JCB which allows you to add a field to a view without adding the field to the database. When will that be useful? When you have a field which maybe is getting data from another table, and you want to change the behavior on the page, based on the data selected, but that selection itself isn't relevant. Or when you want to combine two fields as one in the database, then you could have both fields on the page. [00:00:41](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m41s) On submission in your save area in the Admin View, you can add some custom PHP script to take the value from that other field, and save it in to this field that you intend to combine the two values. You don't want both values to be stored in the database. Or the other option is you have fields on a page, which only get used to generate data in another table. [00:01:16](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m16s) When you save that item, it takes those values put it into the other table and leave one value in this table. Which next time you open it up all those fields are hidden based on that value selection.
We've added a new function to JCB which allows you to add a field to a view without adding the field to the database. When will that be useful? When you have a field which maybe is getting data from another table, and you want to change the behavior on the page, based on the data selected, but that selection itself is not relevant. Or when you want to combine two fields as one in the database, then you could have both fields on the page. [00:00:41](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m41s) On submission in your save area in the Admin View, you can add some custom PHP script to take the value from that other field, and save it into this field that you intend to combine the two values. You do not want both values to be stored in the database. Or the other option is you have fields on a page, which only get used to generate data in another table. [00:01:16](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m16s) When you save that item, it takes those values put it into the other table and leave one value in this table which next time when you open it, all those fields are hidden based on that value selection.
### Multiple Implementations Helps To Get A Sub form On The Page
[00:01:34](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m34s)
It have multiple implementations and helps you to get a sub form on the page or any kind of other field type to be able to use it once, use it within your custom scripting either in JavaScript or in PHP. Previously this wasn't possible. If you add a field to view, it was always going to be stored into the database. But now if you go to Admin Views, let's take one that has the function going. We will use the Admin View fields.
It have multiple implementations and helps you to get a sub form on the page or any kind of other field type to be able to use it once, use it within your custom scripting either in JavaScript or in PHP. Previously this was not possible. If you add a field to view, it was always going to be stored into the database. But now if you go to Admin Views, let's take one that has the function going. We will use the Admin View fields.
### New Feature - None DB
[00:02:24](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m24s)
You'll see that this new feature has replaced your Admin View list option. Because now you have a show in list. Then you have the default which was the previous check or unchecked option, basically is 1 and 0. There are a third one which is called 'None DB'. [00:02:49](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m49s) I have a field called 'Not Required', which is what you would add if you are using JCBs internal conditional option. If you have fields that are required, but within a certain criteria, those fields are hidden, and not required. I'm using this Not Required field [00:03:18](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m18s) to store some values with JavaScript that upon submission, it adapts the validation on the server side. I don't want that value in the database, then I'm using this None DB option. If you changed any other fields, I'm going to do a demonstration. I do want this field in the database, but to show you if you select None DB, it will automatically give you these two notices. [00:03:50](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m50s) The one is saying the None DB option will remove this field from being saved in the database, and then this one only use the None DB option if you're planning on targeting this field with JavaScript or custom PHP to move it's value into another field that does get saved to the database. In one form or another. It is saying to you that if you use this value, we are not going to store whatever is placed in it [00:04:21](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m21s) in the database for you. You will need to manually do that. That's why it's there. It's for customization to your components behavior. You'll see that it also clears out all your selections, because none of these features will be of use, or available to this field because this field [00:04:47](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m47s) after saving, dumps the value and it doesn't exist unless you grab it and use it into your script. If you use the list option, we have this automated counter adding. [00:05:08](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m08s) Every time you do that if counts all the fields that are available in your script. It adds the next logic number. Our Purpose here is to show you that there is a new None DB [00:05:32](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m32s) field behavior. Some of you have been requesting. I also needed it in the past. It's available now. You can try it out play with it. If it doesn't make sense to you just don't use it.
It may be seen that this new feature has replaced your Admin View list option because now you have a 'Show in list'. Then you have the 'Default' which was the previous check or unchecked option, basically is 1 and 0. There are a third one which is called 'None DB'. [00:02:49](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m49s) I have a field called 'Not Required', which is what you would add if you are using JCB's internal conditional option. If you have fields that are required, but within a certain criteria, those fields are hidden, and not required. I am using this 'Not Required' field [00:03:18](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m18s) to store some values with JavaScript that upon submission, it adapts the validation on the server side. I do not want that value in the database, so I am using this 'None DB' option. If you changed any other fields, I am going to do a demonstration. I do want this field in the database, but to show you if you select 'None DB', it will automatically give you these two notices. [00:03:50](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m50s) The one is saying the '_None DB option will remove this field from being saved in the database_', and then this one '_only use the 'None DB' option if you're planning on targeting this field with JavaScript or custom PHP to move it's value into another field that does get saved to the database_'.<<<<<<<<
In one form or another. It is saying to you that if you use this value, we are not going to store whatever is placed in it [00:04:21](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m21s) in the database for you. You will need to manually do that. That's why it's there. It's for customization to your components behavior. You'll see that it also clears out all your selections, because none of these features will be of use, or available to this field because this field [00:04:47](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m47s) after saving, dumps the value and it doesn't exist unless you grab it and use it into your script. If you use the list option, we have this automated counter adding. [00:05:08](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m08s) Every time you do that if counts all the fields that are available in your script. It adds the next logic number. Our Purpose here is to show you that there is a new None DB [00:05:32](https://www.youtube.com/watch?v=6OTRDIgxgq0&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m32s) field behavior. Some of you have been requesting. I also needed it in the past. It's available now. You can try it out play with it. If it doesn't make sense to you just don't use it.