Jump to content

Sonelal Singh

Member Since 01 Jul 2015
Offline Last Active Sep 30 2015 08:16 AM

Topics I've Started

Has the problem(set_relation with callback_column problem solved) been solved with new...

30 September 2015 - 07:25 AM

Hi friends,
Problem : - callback_column and set_relation together - set_relation overrides callback_column.
‚ÄčI am struggling with this from long time and just want to know if this issue has been fixed or not from new version of Grocerycrud
Even below provided workaround is also not working in my case.
function unique_field_name($field_name) {
     return 's'.substr(md5($field_name),0,8); //This s is because is better for a string to begin with a letter and not with a number


Category - Sub Category display

22 September 2015 - 03:17 AM

I have a question on previous forum(mentioned below)




How can I use below code when we have to use category with multiple fields(for example editing/adding user info).

I have two tables(users and category) like below - 

  • "users" table have following  fields --->user_id,name,gender,category.
  • "category" table have following fields ---> id,category,parent_id


       $crud = new grocery_CRUD();
        $crud->set_relation('category', 'categories', 'category');
       /* Add this customisation for parent_relation */
        $primary_id_field  = 'id';
        $table_name   = 'categories';
        $relation_field_name = 'parent_id';
        $parent_field   = 'parent_id';
        $title_field   = 'category';
        $title_display_as  = 'Select Categoria';
        $where    = array('stato'=>'1');//not required
        $same_table   = true; //not required, the default is false
        $output['output'] = $crud->render();

        $this->load->view('template', $output);


Here how can I populate category like post-1-0-41549700-1334271141_thumb.png  when I am using two tables.




Thanks in advance.

Unable to access an error message corresponding to your field name

17 July 2015 - 06:49 AM



I want to add email id validation such that email id must be of same domain not other domain.


For this I have written below code - 



        $crud = new grocery_CRUD();



        $crud->fields('empcode', 'firstname','lastname','email','password');

        $crud->required_fields('empcode', 'firstname', 'email', 'password');


        $crud->set_rules('email', 'Email', 'validate_emailid');


and I have defined "validate_emailid" function in same controller like below -

       function validate_emailid($email)
               $str = explode("@",$str);       
                                echo $this->form_validation->set_message("validate_emailid","Other domain Email id are not allowed ");
                                return FALSE;
but I am getting below error 
"Unable to access an error message corresponding to your field name Email.(validate_emailid)".
Can you guys help me to resolve this issue.Thanks in advance.











Custom column value not showing in view/read?

02 July 2015 - 01:28 PM



I have calculated an age by date of birth(dob) field from my database and I am able to calculate age and display it on list page.

But on view/read page all fields value displaying as expected, except age. Below is my code - 


 $crud = new grocery_CRUD();
$crud->required_fields('empcode', 'firstname', 'lastname', 'email', 'phone', 'password', 'department', 'role', 'status');
$crud->columns('empcode', 'firstname','lastname','email','phone','department', 'role', 'status', 'designation', 'team','Tenure','supervisor','created_date');
$crud->fields('empcode', 'firstname','lastname','email','phone','department', 'role', 'status', 'designation', 'team','supervisor','Tenure');
$crud->callback_column('created_date', array($this, 'callback_date'));
//this field I want to display on my read/view page 
$crud->callback_column('Tenure', array($this, 'callback_calculate_tenure'));
// Field Setup
// Relations
 $crud->set_relation('supervisor','ci_users','{firstname} {lastname}');
$crud->set_rules('email', 'Email', 'required|valid_email');
 $output['output'] = $crud->render();
 $output['title'] = "abc";
 $output['userrole'] = $this->session->userdata('role');
 $output['pagehead'] = "User Management";
$output['output'] = $crud->render();


So what is wrong with my code,why age is not showing on read page.

Note:- I am using version 1.4.2


How can I convert datetime field to "Y-m-d" formate

01 July 2015 - 11:01 AM



I have a field(create_date) in USER table.This stores default datetime(2015-07-01 03:05:34) value in the table as its value.

When I am displaying this value in front end it display as "01/07/2015 - 00:00". But I want to display date as "2015-07-01", To achieve this I used this code $crud->field_type('created_date', 'date') for formatting.So now it display as "01/07/2015".


So my question is how can I display this date as "2015-07-01".