Jump to content


Member Since 23 Mar 2016
Offline Last Active Apr 12 2016 10:43 AM

Topics I've Started

input type=number

23 March 2016 - 07:10 PM



I would like to suggest the the input type for numeric values be changed to number from text. It should be backwards compatible with all browsers and allows adaptive keyboards to be displayed on mobile devices.


In the same vein, it would be nice if the framework recognized other numeric types as numeric, e.g. float, double, decimal...

Compound unique constraints

23 March 2016 - 07:06 PM



I had to add validation to my form input that checks that a compound constraint is not going to be violated. In this case I have two columns in my table 'team' and 'match' and the combination must be unique. So I coded this - it handles updates and adds:

        public function stats($op = null, $id = null) {
                $this->grocery_crud->set_rules('team', 'Team', 'callback_unique_team_and_match['.$id.']');
                $output = $this->grocery_crud->render();


        public function unique_team_and_match($team, $pk)
                $match = $this->input->post('match');

                $this->db->where('team', $team);
                $this->db->where('match', $match);

                if ($pk != null) {
                        // This is an update
                        $this->db->where('id !=', $pk);
                $result = $this->db->get('stats');

                if($result->num_rows() > 0)
                        $this->form_validation->set_message('unique_team_and_match',"There is already an entry for team $team and match $match");
                        return false;
                        return true;

Exact search question

23 March 2016 - 11:12 AM


I have some questions about searching. It looks like the code is hard-wired to perform 'like' searches rather than exact matches. This gives some counter-intuitive results when the column being searched is a number where, in my opinion, people are more likely to want to be able to perform an exact match e.g. 'show me all accounts where the balance is 0'.

So I was wondering how I would start looking at implementing such a feature, possibly by allowing the user to enter a search term into the search box, such as '< 0' or '> 0 and < 100'?

Which brings me to another question. When I search on a column displaying floating point numbers it seems to be treating those columns like text. For example, a database column containing a decimal number might be formatted in the table like 0.0000. When I search on that column it still performs a 'like' search, so if I enter 0, it will return any row where that column contains a zero anywhere, e.g. 4.3210 will be returned as well as 0.0000. Where is this number-to-text conversion taking place such that a 'like' search will actually work?

So finally one more question. If I delve into the source code I see various different field types, but none of them relate to real numbers. In fact the only numeric type is Integer. So how are real numbers treated?