My scenario is that I have a field in a table called Stock_Qty that when it is changed I need to update the Stock_Date field with the current date and then the user can replace the date if they don't want todays date to be stored. There are other fields in the record so I can't rely on the last modified date as the Stock_Qty may or may not have been changed when the record was last saved.
Ignore Last Updated as it really a Stock Available date
I have been looking for something in Javascript or an ability already baked into Joomla but have came up short. I suspect the answer is in Javascript but it is something I still have to learn a lot more about and I have looked through a lot of Joomla code in /libraries/cms/html
but haven't found anything like what I want to do.
I have been looking for an example around the onchange=
field of the <input>
statement on the Form mainly because I have been doing some hacking on a Filter field recently and I can see that onchange=
and onclick=
are able to effect changes on another field.
I have considered storing the value for Stock_Qty and doing a before and after compare in the model before it is saved however it gets complex trying to then work out if the users has provided a new date or if it is the date retrieve from the table. I am trying to avoid more calls to the table to check each record when it is saved.
I haven't been able to think of any examples in Joomla that do something similar either.
Any assistance appreciated and I will reply, I monitor JSE daily.
For this question I am trying to find a solution for when Stock_Qty is changed via a simple edit Form, however I also need to handle a file import changing the Stock_Qty so I have been looking at code for changing the date at the time the record is written to the table as well, overriding updateObject in /libraries/joomla/database/driver.php, therefore I am open to suggestions outside the scope of just Input fields and JS if it is more elegant.