Items validation


How can I validate items in before invoice save?
I tried using callbacks but for some reason these are never fired, I wasted a few hours on this but no result.
I tried sending the items as an array since codeigniter does support based on the documentation but the problem was with jquery. Codeigniter expect items[0] => “snickers”, but jquery sends { name = “items[0]”, value=“snickers”}…

please advise.


What exactly do you want to achieve or what do you want to validate?

I want to validate quatities and prices, don’t want any zero or negative values.

Hmm okay.
There are validation rules for items in /application/modules/invoices/models/mdl_items.php Line 41 which could be used. Take a look at the Codeigniter validation documentation, I think this will do the thing.

thanks for the reply.
I’m aware of these but this not the issue i’m facing.
the issue I’m facing is that when invoice is save the item are sent as json and I wasn’t able to run the validation rules on that json.
A couple of answers I found on stackoverflow recommended the use of callbacks, but like I said earlier callbacks are not fired for some reason. I tried it on multiple other fields, trying different scenarios but to reveal.
Is there anything missing that prevents callback from firing ?
Can you please give an example of how to use callbacks on ip?


Well I don’t have the time to dive into Callbacks and how they could work because InvoicePlane is not using a standardized way to handle forms.

Another idea: directly tweak the ajax handling in /modules/invoices/controllers/ajax.php where all items will be processed and saved.