KiKu
KiKu

Reputation: 377

How to save textbox value in the database

How to save textbox value in the database How to save textbox value in the database (Textbox value populated based on other textbox input value)

Upvotes: 0

Views: 282

Answers (1)

Pavel Shkleinik
Pavel Shkleinik

Reputation: 6347

Solutions proposed in comments to the question seem to be reasonable, but I would offer one more if you don't mind. If TotalRate field's value is somehow important/vulnerable then I would never store it in database to avoid possible malicious manipulations from app users. In case there is some good reason/requirement to store calculated value in database I would go with calculation on the server side and handle it in onBeforeCreate and onBeforeSave model events:

// onBeforeCreate/onBeforeSave event handlers
record.TotalRate = record.PerHourRate * record.HoursNumber;

Upvotes: 1

Related Questions