New version 1.1.2 is now released with two new features:
- Hidden fields in your form.
- Adding custom actions to your list.
Enjoy…
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
April 11, 2011 3:24am
Subscribe [77]#196 / Sep 23, 2011 5:25pm
New version 1.1.2 is now released with two new features:
- Hidden fields in your form.
- Adding custom actions to your list.
Enjoy…
#197 / Sep 23, 2011 6:34pm
- Hidden fields in your form
Thanks! but ... how i can use it… ¿what is the method?
#198 / Sep 23, 2011 6:53pm
- Hidden fields in your form
Thanks! but ... how i can use it… ¿what is the method?
I just updated the library. I know write a small example for this.
It is simple you just change your field type with the change_field_type function .
For example if you have a field with name category_id you just use the change_field_type(‘category_id’,‘hidden’,4); and there you go . I will have more to my website ASAP.
#199 / Sep 27, 2011 6:56pm
do you mind having the option to declare the primary key(s) and database structure? the show_columns routine is not very nice to change to other databases.
Perhaps you could think of it as a cache - if you hardcode the field definitions and keys it would reduce the load on the sql server.
make show_columns optional, (add it to forge driver) - allow users to hardcode the object so it doesn’t make so many calls to the database server and is more portable.
Definitely make sure you can use multiple primary keys or various types.
I’d love to suggest some mods like the previous guy to make the grocery crud more agnostic to the sql server. instead of trying to emulate the show_columns function make show_columns into a separate function that generates a table structure - allow users to bypass show_columns call with static table passed.
I’ve used phpmaker before and this is how it addresses the various databases it comes across (based on adodb php so it works with dozens of databases).
I don’t have time to fork your code - and i can’t imagine that is appreciated but would like to suggest code to be included so grocery crud can work with sqllite,mysql,sql server, anything ODBC (excel spreadsheets) - you name it. I think it would definitely add alot of value to the project.
Why does the code after show_columns explicitly define some variables then do an array merge on the rest of the returned data? It’s hard to guess what you expect and not having mysql - even harder to guess which fields you are actually using(pri,uni,mul, auto_increment) without searching through all the files for values - i’d love to help if you don’t mind me bugging you to ask about specific functions that could be made more generic (sql wise).
#200 / Oct 05, 2011 12:23pm
Thanks @mrkrad for your suggestions
#201 / Oct 11, 2011 11:47pm
Good Day. Thanks and Congratulations on your great CRUD app.. it just save me more time….
I’m a newbie at codeigniter and before i use the groceryCRUD, I tried to use the Flexigrid..
and because i’m still a newbie on how ci works, it took me one day to show data on the Flexigrid..but when i try groceryCRUD, it just took me hours to show data using flexigrid as a template…
but i need a little help, how can i show data from 2 tables, i mean using JOIN?, i did it on flexigrid because i created my own query. I think the answer is to use the set_model function..but i don’t know how to use it, especially the set_relation_n_n.
i hope anybody can help…i’m a bit lost..
thanks.
#202 / Oct 12, 2011 12:21am
Good Day. Thanks and Congratulations on your great CRUD app.. it just save me more time….
I’m a newbie at codeigniter and before i use the groceryCRUD, I tried to use the Flexigrid..
and because i’m still a newbie on how ci works, it took me one day to show data on the Flexigrid..but when i try groceryCRUD, it just took me hours to show data using flexigrid as a template…but i need a little help, how can i show data from 2 tables, i mean using JOIN?, i did it on flexigrid because i created my own query. I think the answer is to use the set_model function..but i don’t know how to use it, especially the set_relation_n_n.
i hope anybody can help…i’m a bit lost..
thanks.
What do you mean exactly with the JOIN ? If you want to do some basic relations there are 2 kind of automatic relations. First of all is :
1. the set_relation function that have a simple relation, for example if you have a customer_id and you have customers table, if you need the dropdown of customers and the join appears automatically on the flexigrid table. See an example at: http://www.grocerycrud.com/crud/example/set_a_relation, its simple an easy and you just add 3 parameters.
2.If you want more complicated relations such as a middle table to have the relations, then you need the set_relation_n_n. Its really simple. Just see the example http://www.grocerycrud.com/crud/example/set_a_relation_1_n ( I know you have already seen that ) and add the fields that you want . There are really easy because even if it is complicated , you just add 6 parameters and that’s it.
If you still have problems with this, then yes, you will use the set_model, but it’s not suggested if you are new to codeigniter. First try the “automated” joins of grocery CRUD and then go to this kind of solution.
But I don’t know what is your exactly problem with the joins, so I can’t give you a specific solution. For example : I have a table books and I want to do a join with customers etc. etc…
#203 / Oct 12, 2011 1:04am
Thanks for the fast response and sorry i don’t know what term is right to use.:cheese:
OK, here is what i want to happen..
The Image (flexgridview1) is the result when i used flexigrid, notice the columns Unique ID, Last Name, First Name, Phone and Branch..they belong to table name “user_profiles”. The remaining columns, Username, Email, Last IP and Last Login belong to different table named “users”. The results are from the SQL query where i join the 2 tables.
$querys['main_query'] = "SELECT user_profiles.id, user_profiles.fname, user_profiles.lname, user_profiles.uid_pref, user_profiles.phone,
user_profiles.branch, users.username, users.email, users.last_ip, users.last_login
FROM user_profiles
INNER JOIN users
ON user_profiles.id=users.idwhat i needed was to be able to reproduce that same result in groceryCRUD. I know it is possible its just that i don’t know how to do it…
Thank you very much, sir john.😊
here are the tables structure(might be useful):
users
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) COLLATE utf8_bin NOT NULL,
`password` varchar(255) COLLATE utf8_bin NOT NULL,
`email` varchar(100) COLLATE utf8_bin NOT NULL,
`activated` tinyint(1) NOT NULL DEFAULT '1',
`banned` tinyint(1) NOT NULL DEFAULT '0',
`ban_reason` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`new_password_key` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`new_password_requested` datetime DEFAULT NULL,
`new_email` varchar(100) COLLATE utf8_bin DEFAULT NULL,
`new_email_key` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`last_ip` varchar(40) COLLATE utf8_bin NOT NULL,
`last_login` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=15 ;user_profiles
CREATE TABLE IF NOT EXISTS `user_profiles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`fname` varchar(255) COLLATE utf8_bin NOT NULL,
`lname` varchar(255) COLLATE utf8_bin NOT NULL,
`uid_pref` varchar(255) COLLATE utf8_bin NOT NULL,
`phone` varchar(255) COLLATE utf8_bin NOT NULL,
`branch` varchar(255) COLLATE utf8_bin NOT NULL,
`address` varchar(255) COLLATE utf8_bin NOT NULL,
`country` varchar(20) COLLATE utf8_bin DEFAULT NULL,
`website` varchar(255) COLLATE utf8_bin DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=10 ;
#204 / Oct 12, 2011 1:25am
Thanks for the fast response and sorry i don’t know what term is right to use.:cheese:
OK, here is what i want to happen..
The Image (flexgridview1) is the result when i used flexigrid, notice the columns Unique ID, Last Name, First Name, Phone and Branch..they belong to table name “user_profiles”. The remaining columns, Username, Email, Last IP and Last Login belong to different table named “users”. The results are from the SQL query where i join the 2 tables.
$querys['main_query'] = "SELECT user_profiles.id, user_profiles.fname, user_profiles.lname, user_profiles.uid_pref, user_profiles.phone, user_profiles.branch, users.username, users.email, users.last_ip, users.last_login FROM user_profiles INNER JOIN users ON user_profiles.id=users.idwhat i needed was to be able to reproduce that same result in groceryCRUD. I know it is possible its just that i don’t know how to do it…
Thank you very much, sir john.😊
here are the tables structure(might be useful):
users
CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(50) COLLATE utf8_bin NOT NULL, `password` varchar(255) COLLATE utf8_bin NOT NULL, `email` varchar(100) COLLATE utf8_bin NOT NULL, `activated` tinyint(1) NOT NULL DEFAULT '1', `banned` tinyint(1) NOT NULL DEFAULT '0', `ban_reason` varchar(255) COLLATE utf8_bin DEFAULT NULL, `new_password_key` varchar(50) COLLATE utf8_bin DEFAULT NULL, `new_password_requested` datetime DEFAULT NULL, `new_email` varchar(100) COLLATE utf8_bin DEFAULT NULL, `new_email_key` varchar(50) COLLATE utf8_bin DEFAULT NULL, `last_ip` varchar(40) COLLATE utf8_bin NOT NULL, `last_login` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=15 ;user_profiles
CREATE TABLE IF NOT EXISTS `user_profiles` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `fname` varchar(255) COLLATE utf8_bin NOT NULL, `lname` varchar(255) COLLATE utf8_bin NOT NULL, `uid_pref` varchar(255) COLLATE utf8_bin NOT NULL, `phone` varchar(255) COLLATE utf8_bin NOT NULL, `branch` varchar(255) COLLATE utf8_bin NOT NULL, `address` varchar(255) COLLATE utf8_bin NOT NULL, `country` varchar(20) COLLATE utf8_bin DEFAULT NULL, `website` varchar(255) COLLATE utf8_bin DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=10 ;
First of all you have a wrong query . Its not
SELECT user_profiles.id, user_profiles.fname, user_profiles.lname, user_profiles.uid_pref, user_profiles.phone,
user_profiles.branch, users.username, users.email, users.last_ip, users.last_login
FROM user_profiles
INNER JOIN users
ON user_profiles.id=users.idbut…
SELECT user_profiles.id, user_profiles.fname, user_profiles.lname, user_profiles.uid_pref, user_profiles.phone,
user_profiles.branch, users.username, users.email, users.last_ip, users.last_login
FROM user_profiles
INNER JOIN users
ON user_profiles.user_id=users.id( its user_profiles.user_id=users.id and not user_profiles.id=users.id)
This is 1-1 relation and I didn’t included to grocery CRUD yet as automated , so you need a custom query to do it. So you must use the set_model. There is no other solution for now. Try to use the set_model and if you have any problem , just send me back.
#205 / Oct 12, 2011 1:33am
I think you’re right, ok i’ll try my best and get back to you if i have encountered problems.
thanks john, and again congratulations on your great CRUD app..
hope to see more features soon…
:lol:
#206 / Oct 13, 2011 11:51am
New version of grocery CRUD v.1.1.3 is now released. A change log of the new version you can see it below:
-Changing the functionality of the private method _theme_view. Now it’s not dependent with the Loader of codeigniter.So every template controller, HMVC, e.t.c. can work well with grocery CRUD now.
-Changing the library core and make it more minimal and more powerful.
-New method unset_jquery. Very useful, if you already have the jquery library at your basic template.This is good to avoid jquery conflicts.
-BUG fix. No more conflicts between flexigrid tables. There was a cookie conflict between different lists.
-BUG fix. The set relation now works if you add the same table name twice.
-Renaming the folder public to assets.
-Grocery CRUD is now ready to be a spark.
-Changing the functionality and the javascript of the uploader. There is no need to have $config[‘enable_query_strings’] set to true anymore.
For more click to
http://www.grocerycrud.com/crud/view/change_logs
#207 / Oct 14, 2011 5:07am
How can add, line in city selection list,
eg.
<select name='officeCode'>
<!-- add this line start -->
<option value='0'>Don't Know</option>
<!-- add this line end -->
<option value='1'>value loaded from table</option>
</select>Below is The Original sample Code used by me,
function employees_management()
{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('employees');
$crud->display_as('officeCode','Office City');
$crud->set_subject('Employee');
$crud->set_relation('officeCode','offices','city');
$output = $crud->render();
$this->_example_output($output);
}#208 / Oct 17, 2011 3:09am
I’ve been using GroceryCrud over the last few days and it’s really excelent.
I have one problem when i have a join in the controller i can’t search by ID using the search field. In the log files i get the following error:
ERROR - 2011-10-17 09:58:20—> Query error: Column ‘id’ in where clause is ambiguous
My controller looks like this:
function requests()
{
$crud = new grocery_CRUD();
$crud->set_table('fq_request');
$crud->set_subject('Request');
$crud->unset_add();
$crud->fields('request_service', 'request_name', 'request_email', 'region_id', 'request_phone', 'request_fax', 'request_for');
$crud->set_relation('region_id','fq_region','region_name');
$crud->unset_texteditor('request_for');
$crud->columns('id', 'request_service', 'request_name', 'request_email', 'request_count');
$crud->order_by('id', 'desc');
$output = $crud->render();
$this->_crud_output($output);
}One way around this would be to make the ID field in the database unique in all tables. I’d rather not have to but if neccessary. Is there any other way around this?
Thanks
Simon
#209 / Oct 18, 2011 2:07pm
I’ve been using GroceryCrud over the last few days and it’s really excelent.
I have one problem when i have a join in the controller i can’t search by ID using the search field. In the log files i get the following error:
ERROR - 2011-10-17 09:58:20—> Query error: Column ‘id’ in where clause is ambiguous
My controller looks like this:
function requests() { $crud = new grocery_CRUD(); $crud->set_table('fq_request'); $crud->set_subject('Request'); $crud->unset_add(); $crud->fields('request_service', 'request_name', 'request_email', 'region_id', 'request_phone', 'request_fax', 'request_for'); $crud->set_relation('region_id','fq_region','region_name'); $crud->unset_texteditor('request_for'); $crud->columns('id', 'request_service', 'request_name', 'request_email', 'request_count'); $crud->order_by('id', 'desc'); $output = $crud->render(); $this->_crud_output($output); }One way around this would be to make the ID field in the database unique in all tables. I’d rather not have to but if neccessary. Is there any other way around this?
Thanks
Simon
Try to do this:
function requests()
{
$crud = new grocery_CRUD();
$crud->set_table('fq_request');
$crud->set_subject('Request');
$crud->unset_add();
$crud->fields('request_service', 'request_name', 'request_email', 'region_id', 'request_phone', 'request_fax', 'request_for');
$crud->set_relation('region_id','fq_region','region_name');
$crud->unset_texteditor('request_for');
$crud->columns('fq_request.id', 'request_service', 'request_name', 'request_email', 'request_count');
$crud->display_as('fq_request.id','id');
$crud->order_by('fq_request.id', 'desc');
$output = $crud->render();
$this->_crud_output($output);
}I didn’t test the code but probably this will solve the problem.
#210 / Oct 18, 2011 3:15pm
Try to do this:
function requests() { $crud = new grocery_CRUD(); $crud->set_table('fq_request'); $crud->set_subject('Request'); $crud->unset_add(); $crud->fields('request_service', 'request_name', 'request_email', 'region_id', 'request_phone', 'request_fax', 'request_for'); $crud->set_relation('region_id','fq_region','region_name'); $crud->unset_texteditor('request_for'); $crud->columns('fq_request.id', 'request_service', 'request_name', 'request_email', 'request_count'); $crud->display_as('fq_request.id','id'); $crud->order_by('fq_request.id', 'desc'); $output = $crud->render(); $this->_crud_output($output); }I didn’t test the code but probably this will solve the problem.
I’ve tried something like this before but did try again. By adding the prefix here:
$crud->columns('fq_request.id', 'request_service', 'request_name', 'request_email', 'request_count');somehow the IDs are not displayed in the CRUD at all. However I did notice now that the search count does seem to work (ie it counts the correct number of records for a search on the ID) but it doesn’t update the display to show the found records.
Thanks,
Simon