Jump to content


Sonelal Singh's Content

There have been 8 items by Sonelal Singh (Search limited from 27-October 19)


By content type

See this member's

Sort by                Order  

#13191 Has the problem(set_relation with callback_column problem solved) been solved...

Posted by Sonelal Singh on 30 September 2015 - 07:25 AM in I have a question

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.
 
$crud->callback_column($this->unique_field_name('vrsta_id'),array($this,'valueToEuro'));
$crud->set_relation('vrsta_id','vrsta','{vrsta_id}');
 
 
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
}
 
 
 
 
 
 
 

 




#13148 Category - Sub Category display

Posted by Sonelal Singh on 22 September 2015 - 03:17 AM in I have a question

I have a question on previous forum(mentioned below)

http://www.grocerycr...-dropdown-list/

 

 

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

 

       $this->load->library('grocery_CRUD');
       $crud = new grocery_CRUD();
        $crud->set_theme('datatables');
        $crud->set_table('users');
        $crud->set_subject('Users');
        $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
        $this->set_parent_relation($primary_id_field,$table_name,$parent_field,$title_field,$crud,$title_display_as,$relation_field_name,$where,$same_table);       
        
        $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.




#13144 [EXTRA] Categories and Subcategories Dropdown list.

Posted by Sonelal Singh on 21 September 2015 - 07:48 AM in How to and FAQs

Hi web-johnny,

 

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

 

For example - 

 

users table have following  fields --->user_id,name,gender,category

 

and category table have following fields ---> id,category,parent_id

 

 

       $this->load->library('grocery_CRUD');
 
        $crud = new grocery_CRUD();
        $crud->set_theme('datatables');
        $crud->set_table('users');
        $crud->set_subject('Users');
        $crud->set_relation('category', 'ci_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
 
        $this->set_parent_relation($primary_id_field,$table_name,$parent_field,$title_field,$crud,$title_display_as,$relation_field_name,$where,$same_table);
       
        
        $output['output'] = $crud->render();

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

 

 

I am not able to figure out how can I use category field with other tables.

 

 

 

 

 




#12837 Unable to access an error message corresponding to your field name

Posted by Sonelal Singh on 17 July 2015 - 06:49 AM in I have a question

Hi,

 

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 - 

 

 

        $this->load->library('grocery_CRUD');        
        $crud = new grocery_CRUD();
        $crud->set_theme('datatables');

        $crud->set_table('ci_users');

        $crud->set_subject('User');

        $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);       
               if($str[1]=='teamlease.com')
              {
                                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.

 

 

 

 

 

 

 

 

 

 




#12726 Custom column value not showing in view/read?

Posted by Sonelal Singh on 02 July 2015 - 01:28 PM in Bugs / Issues

HI,

 

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->set_theme('datatables');
 $crud->set_table('ci_users');
        
$crud->set_subject('User');
$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
$crud->change_field_type('password','password');
 
// Relations
 $crud->set_relation('supervisor','ci_users','{firstname} {lastname}');
$crud->set_relation('department','ci_departments','department');
$crud->set_relation('role','ci_roles','roles');
$crud->set_relation('status','ci_status','status');
$crud->set_relation('designation','ci_designations','designation');
$crud->set_relation('team','ci_teams','team');
$crud->unique_fields('email');
$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

 




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

Posted by Sonelal Singh on 02 July 2015 - 08:50 AM in Bugs / Issues

Hey Paul,

 

Thanks for your help.

It worked   :) 




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

Posted by Sonelal Singh on 02 July 2015 - 06:16 AM in Bugs / Issues

Hi Paul,

 

Thanks for your reply.

 

In database my field name is "create_date" and date type is "timestamp" and default value is "CURRENT_TIMESTAMP".

 

But when I fetch and displaying this field in front end it display like "30/11/1999" (d/m/y) format.

 

I want to display this field like "1999-11-30".

 

 

 

I have applied you suggestion in my code like below -

 

$crud->callback_columns('created_date', array($this, 'callback_date'));

 

and in same controller I have created callback function like below 

 
public function callback_date($val, $row)
{
        return date('Y-m-d', strtotime($val));
}

 

But I am getting below error

Call to undefined method Grocery_CRUD::callback_columns() 




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

Posted by Sonelal Singh on 01 July 2015 - 11:01 AM in Bugs / Issues

Hi,

 

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".