Added method for writing data from the form to the database in the model.