Welcome Guest, Not a member yet? Register   Sign In
v 1.3.3 grocery CRUD - an automatic Codeigniter CRUD

[eluser]web-johnny[/eluser]
Yes of course without any problem.
You can do this with the simple set_relation so in your case you will have:

Code:
$c = new grocery_CRUD();

$c->set_table('profiles');

$c->set_relation('user_id','users','username');

The field "id" of the Users table is auto-recognized as it is the primary key of the related table.

[eluser]Pieter[/eluser]
@web-johnny
Thanks! I've been playing with Grocery CRUD for a while and it's just awesome!

[eluser]MatthewSchenker[/eluser]
[quote author="web-johnny" date="1329085232"]
I totally believe that it's more powerful by NOT using form_helper....
The callbacks are pretty cool idea and I will try to have more documentation, so users can use them easily without any doubt.[/quote]

Thanks web-johnny!

When I build my forms, I need to do a lot of the options that are available in the CodeIgniter form helper.

I may be wrong, I don't see all the form helper options available in GroceryCRUD? Is this true? It might just be a documentation issue.

Sorry if I'm asking obvious questions!

Thanks,
Matthew

[eluser]Pieter[/eluser]
Hi web-johnny,

I've just worked on a simple users table and ran into an issue with the is_unique validation.
Osci wrote a nice My_Form_validation to solve the is_unique problem when editing: http://ellislab.com/forums/viewthread/192334/

Part of the controller:
Code:
$state = $this->grocery_crud->getState();
$state_info = $this->grocery_crud->getStateInfo();

if( $state == 'insert_validation' )
{
$this->grocery_crud->set_rules('password', 'Password', 'trim|required');
$this->grocery_crud->set_rules('email', 'Email', 'trim|required|valid_email|is_unique[clients.email]');
}

if( $state == 'update_validation' )
{
$this->grocery_crud->set_rules('email', 'Email', 'trim|required|valid_email|is_unique[clients.email.id.'.$state_info->primary_key.']');
}

Now I had to change two things in the grocery_CRUD library to make this happen.
1) Change the getStatInfo() to return a primary_key as it was emtpy on "update_validation".
2) Change the is_unique method into that of the one Osci wrote.

Question: Is there a better way to handle unique fields? And is there a way to extend the grocery_CRUD library?




[eluser]Unknown[/eluser]
[quote author="ilSignorCarlo" date="1316169573"]Hi,
I'm having some problems using Grocery CRUD in my website. I've found out that the problem is actually the URI language identifier library (http://codeigniter.com/wiki/URI_Language_Identifier).

Grocery crud is working, so if I load the examples in the library, at this address: http://localhost/website/examples/offices_management, I can see the table with all the rows, I can sort them and so on. The problem is when I try to add/edit. Indeed, the add button, for example, points here: http://localhost/website/offices_management/add. It gives me an error since the url is missing the "examples" part, that is the controller name.

If I delete the URI language identifier controller it works, but I need it. The problem, I think, is that is doing stuff with the url.

Does anyone know how to solve this?[/quote]


In the library file 'grocery_crud.php' replace all '$ci->uri->segments' with '$ci->uri->rsegments'.

[eluser]Unknown[/eluser]
Hi,
I’m having some problems using Grocery CRUD with my database...
Here my table design.
Orders :
id, products_id,qty,discount, total,etc...
Products:
products_id,unit_price, discounted(bool), etc...

The rule is, if products is discounted, in add or edit orders we can set the discount value(based on orders qty) else field is hidden, and total field is hidden in add or edit but the value will be (unit_price - discount).

i just can't figure out how to get and set those field values using Grocery CRUD.

can someone help me please.

[eluser]bluehat09[/eluser]
--edit--
Just for dumb a$$ as me: in database config file change active records to TRUE!
It works just fine.

@web-johhny: Sorry to bother with this basic question but I can't make it work.
Maybe is something in my configuration, maybe not.

So I tried your basic example but I got all the time:
Fatal error: Call to undefined method CI_DB_mysql_driver:Confusedelect() in C:\xampp\htdocs\...\application\models\grocery_model.php on line 41

I'm sure all files are in place: library, model, assets etc.

Can you help, please?

Many thanks,
Adrian

[eluser]web-johnny[/eluser]
[quote author="mayfield" date="1331176954"]Hi,
I’m having some problems using Grocery CRUD with my database...
Here my table design.
Orders :
id, products_id,qty,discount, total,etc...
Products:
products_id,unit_price, discounted(bool), etc...

The rule is, if products is discounted, in add or edit orders we can set the discount value(based on orders qty) else field is hidden, and total field is hidden in add or edit but the value will be (unit_price - discount).

i just can't figure out how to get and set those field values using Grocery CRUD.

can someone help me please.[/quote]

@mayfield you have double post this question. And you couldn't even wait one day for the answer...!

[eluser]bluehat09[/eluser]
-- edit --

Discover add_action()

http://www.grocerycrud.com/documentation...add_action

No answer need it. Thanks.

Hi,

There is a way to use gCRUD to make custom actions on table view? E.g: Add near delete, edit a custom action "complete order".

I meant move records from one table to another. Let's say I have one order in orders table and I want to move one record by its id to closed_orders table.

Thank you.


[eluser]web-johnny[/eluser]
[quote author="bluehat09" date="1331637223"]-- edit --

Discover add_action()

http://www.grocerycrud.com/documentation...add_action

No answer need it. Thanks.

Hi,

There is a way to use gCRUD to make custom actions on table view? E.g: Add near delete, edit a custom action "complete order".

I meant move records from one table to another. Let's say I have one order in orders table and I want to move one record by its id to closed_orders table.

Thank you.

[/quote]

You can use the callback_column for that and add it like a link or a button. There are two parameters there ($value, $row). You can take for example the $row->id and have queries there or an information for another table e.t.c.




Theme © iAndrew 2016 - Forum software by © MyBB