When A Check Box Is Checked It Adds Text To Database Field

I have a form for people to submit educational resources and there is a section where they check all of the grades which the resource would be appropriate for. My question is their a way to pass text to a database field based on the check boxes a user checks. For example, if a user checked K, 1st, 2nd and 5th boxes then it would pass the text: ‘K, 1, 2, 5’ to the database field, Grade.

Checkbox element usually represents a boolean value.
It is possible with beforeInsert Data Hook but what is the use case ?
What are you tring to achieve ?

Thanks for the response. I am trying to have people submit educational resources into a community resource database. On the other side of it is people looking for resources can filter the resource database by grade level (or a few other fields.)

I want to make it so that a user only has to check the boxes next to the grade levels and it will insert the text values into the Grade field so that it then can be filtered.

I’ll give you an example of using before insert Hook:
Assuming that each education level has a boolean field i the DB

export function myCollection_beforeInsert(item, context) { 
   cosnt preK = item.prek ? 'Pre-K' : '';
   const k = item.k ? 'K' : ''; 
   const first = item.first ? '1st' : '';
   const second = item.second ? '2nd' : '';
   item.searchableText = `${preK} ${k} ${first} ${second}`;
   return item; 

Add new text field named: “searchableText” in the database collection.
Good Luck!