> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt ## Resource: Processing User Input Before it is Stored in a Collection with Data Hooks ## Article: Processing User Input Before it is Stored in a Collection with Data Hooks ## Article Link: https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/user-input/processing-user-input-before-it-is-stored-in-a-collection-with-data-hooks.md ## Article Content: # Velo Tutorial: Processing User Input Before it is Stored in a Collection with Data Hooks Sometimes you want to validate, alter, or otherwise manipulate user input that you collect using a form before it is stored in your collection. To do so, you can create a [data hook](https://support.wix.com/en/article/about-data-hooks) that intercepts newly created items before they are stored in your collection. Then you can change the item any way you like and that changed item will be what is added to your collection. To demonstrate this concept we use an example of a real estate site that has an inquiry form. Users will fill out the form to submit their information. Before the user data is saved in a collection, we will use a hook to format some of the data and add some information to the new item if certain conditions are met. ### Prerequisites This article assumes you are familiar with creating [database collections](https://support.wix.com/en/article/about-database-collections) and [user input forms](https://support.wix.com/en/article/cms-creating-a-custom-form-with-input-elements-that-submit-to-your-collection). You also might want to read more about [data hooks](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/hooks/about-data-hooks.md) before continuing. ### Collection We begin by creating a database collection that stores the information users submit using a form. Since we are using the collection to store user input, we set its permissions using the **Form Submission** preset. For our example, we call our collection PotentialClients and it has the following fields: * First Name - Text * Last Name - Text * Email - Text * Phone - Text * Type -Text (Value will be "Buy" or "Rent") * Bedrooms - Number * Bathrooms - Number * Price - Number * Priority - Boolean ### Input Form The next step is to create a user input form. Because a hook will be used to modify the collection item that is created when a user submits the form, the fields in the form do not need to exactly match the items in the collection. In our example, we use the following form:
**Note:** You may want to create the **toUpperFirst()** function in a separate file and import it in **data.js**. That will allow you to use the function elsewhere.* * * On lines 5-7, the hook checks the values of the `price` and `type` properties. If the potential client is looking to buy a property over $1,000,000, the item in the collection will be marked as a priority item. if(item.price > 1000000 && item.type === 'Buy') { item.priority = true; } * * * Finally, on line 9, the hook returns the modified item. That means the item inserted into the collection will have the formatted names and the priority field set correctly. return item;