Jump to content


saulimus

Member Since 11 Jul 2012
Offline Last Active Mar 27 2013 12:07 PM
-----

#5252 How to stop grocery crud cutting from string fields in list view

Posted saulimus on 24 January 2013 - 08:05 AM

application\config\grocery_crud.php:

$config['grocery_crud_character_limiter'] = 0;



#4398 Callback_before_insert is not working in a dabase relation.

Posted saulimus on 22 November 2012 - 08:42 PM

You can only modify the $post_array using callback_before_insert. So it's not very useful in this case...

You need the prefix 'callback_' before your actual function name in set_rules(), like this:
$crud->set_rules('officeCode', 'Office City','callback_officeCode_check');
Then this should work:

function officeCode_check($str)
{
     $num_row = //My query here;
     if ($num_row >= 1)
     {
         $message = $this->lang->line('is_unique');
         $message = sprintf($message, 'Office City');
         $this->form_validation->set_message('officeCode_check', $message);
         return FALSE;
     }
     else
         return TRUE;
}

Also, you'll have to load the form_validation library before using it.


#3607 managing ion auth tables

Posted saulimus on 25 September 2012 - 06:57 AM

You're missing this relation:
$crud->set_relation_n_n('groups', 'users_groups', 'groups','user_id','group_id','description');
Without this line, it's trying to insert the 'groups' field into your 'users' table instead of 'users_groups'...
EDIT: Also, you don't need callback_after_update when it's working properly... so don't forget to remove it.


#3605 managing ion auth tables

Posted saulimus on 25 September 2012 - 06:17 AM

When editing or adding?... can you post your code?...


#3584 Size of a request header field exceeds server limit

Posted saulimus on 22 September 2012 - 12:11 PM

You should take a look at this thread:
http://www.grocerycr...o-back-to-list/


#3259 Concatenate two or more fields into one field?

Posted saulimus on 05 September 2012 - 02:14 PM

j-curato's suggestion should work if the fields are in another table...


If they aren't, one option is to create an SQL View:


CREATE VIEW User_view AS
SELECT id, CONCAT(First_name, ' ', Last_name), 'DOB', 'City', 'Status' FROM User;

Then you need to specify to GroceryCrud what the primary key of your view is before using it:
$crud->set_primary_key('User_view', 'id');

Another method is using a callback:
// Added a new column called 'fullname'
// First_name and Last_name need to be included to be able to reference them in the callback
$crud->columns('id', 'Full_name', 'First_name', 'Last_name', 'DOB', 'City', 'Status');
// unset the other name columns from view
$crud->unset_columns('First_name', 'Last_name');
$crud->callback_column('Full_name',array($this,'_cb_col_full_name'));

public function _cb_col_full_name($value, $row)
{
$str = $row->First_name.' '.$row->Last_name;
return $str;
}

Hope all the code works, just typed without checking it... :P
I don't have access to my dev environment right now...


#3218 Updating from 1.2.1 to 1.3 - TinyMCE not working

Posted saulimus on 03 September 2012 - 07:09 PM

I found the fix for it, see my post:
http://www.grocerycr...osen/#entry3201


#3201 jQuery 1.8.0 and TinyMCE + jQuery UI Chosen

Posted saulimus on 03 September 2012 - 06:54 AM

Update!

I found that the TinyMCE jQuery plugin included GroceryCrud 1.3 seemed to be the problem.
To fix the problem, I downloaded the latest TinyMCE version from:
http://www.tinymce.c...lop/nightly.php
Then I copied the file "tinymce\jscripts    iny_mce\jquery.tinymce.js" in the archive to the project directory "assets/grocery_crud/texteditor/tiny_mce" replacing the older one. Now the dropdowns work again. Hope this helps someone else as well.

Edit: Clarified instructions...


#3103 Try to "CRUD" from a view

Posted saulimus on 24 August 2012 - 01:25 PM

Set the primary key for the view and it will work:
http://www.grocerycr...set_primary_key

set_primary_key('ID', 'dist_cli')

You might have a problem because both your tables have the primary key as 'ID' so it can't guess which one you're referring to.
You'd have to try and see what happens... but I guess it would be ok if you only use the view for reading data.


#3070 managing ion auth tables

Posted saulimus on 22 August 2012 - 09:16 AM

Yes, that's how I did it... :)
Here's some of the code, hope it helps in finding your solution:
http://codepad.org/7O6vEY6h

I also added some jQuery to the page to disable the password fields until the checkbox is checked, just to make it look nicer:
http://codepad.org/0mWiA19N


#3039 managing ion auth tables

Posted saulimus on 20 August 2012 - 02:07 PM

I did exactly that with ionauth:
-a checkbox titled "Change password?"
-two password fields
-validation rules for password length etc.
-callback before update to check if:
   -the checkbox is selected
   -the passwords are the same
   etc.
So if I can do it you can too. :)


#2635 DataTables pagination bug - found fix

Posted saulimus on 11 July 2012 - 09:27 AM

Hi!

I found a bug in GroceryCrud when using DataTables.
The bug makes it not possible to click 'Next' and shows the following line wrong:
Displaying 1 to 010 of 23 items
The line above should obviously be "10" and not "010".

File: 'assets\grocery_crud\themes\datatables\views\list_template.php'
Line:
var default_per_page = '<?php echo $default_per_page;?>';
Cause: Datatables expects default_per_page to be a number and not a string

How to fix: Remove the single quotes :)
var default_per_page = <?php echo $default_per_page;?>;

You can check the bug out at:
http://www.grocerycr...yees_management