Populating dropdown from another table
- Single Page
Posted 20 August 2012 - 18:37 PM
I am new to using grocerycrud. I am making a simple product management system.
I have crud on one table called 'categories'
Now i am trying to generate crud on another table called 'products'
When I click on 'Add Product', i want a dropdown field for user to select the category for that particular product.
The dropdown should contain the name from the previous table called 'categories'
I believe its an easy thing to accomplish but unable to find the specific solution.
Regards.
Posted 20 August 2012 - 19:46 PM
Yes, you are right, this is really easy to do with grocery CRUD Please, read the description of set_relation() function. I think that will help you.
On the other hand, if you want, you can use the set_relation_n_n() function.
For more info also read the topic categories-and-subcategories.
Best regards!
Posted 20 August 2012 - 19:59 PM
I agree, I think the set_relation is what you are searching for. Take also a look at: http://www.grocerycrud.com/examples/set_a_relation , if you are still having problems you can copy the structure of the tables as a reply.
Kindest Regards
Johnny
Posted 20 August 2012 - 20:04 PM
Also i have one more question: i am uploading images for products forms. What i want is once images get uploaded, i can see a small thumbnail in the listing of flexigrid besides the name of products...is it possible anyhow?
Posted 20 August 2012 - 20:30 PM
[b]1.[/b] Download the latest nightly version from github from : https://github.com/s.../zipball/master .
If you are interested you can check some print-screens: [attachment=249:2012-08-20_212654.png] [attachment=250:2012-08-20_212730.png] [attachment=251:2012-08-20_212921.png]
or [b]2.[/b] You can have a simple callback_column. For more you can see an example at: http://www.grocerycr...callback_column
In your case you will have something like this:
public function products()
{
$c = new grocery_CRUD();
$c->set_table('products');
$c->set_subject('Product');
$c->columns('product_title','image_url','status','priority');
$c->callback_column('image_url',array($this,'_callback_image_thumbnail'));
$output = $c->render();
$this->_view_output($output);
}
public function _callback_image_thumbnail($value, $row)
{
return "<img src='/assets/uploads/".$row->image_url."' width='100' />";
}
Posted 21 August 2012 - 12:33 PM
how far is v 1.3 from stable? do you recommend for production enviroment?
and if I try it, just overwrite all files? or must old files be deleted?
Posted 22 August 2012 - 08:51 AM
Thanks For Your Great Work With G-Crud, actually I'm new To G-Crud and I've some work to do so I decided to use it on This Project.
i have one simple question , can i upload multiple images and made something like agallery,
how can i install fancy box plugin to v 1.2.3 ?
i will be grateful if you attached an actual example like one in the quoted post.
Thank You !
Posted 22 August 2012 - 12:07 PM
This is a different library that I have created (still is beta but it works fine) with name Image CRUD you can check http://www.web-and-development.com/image-crud-an-automatic-multiple-image-uploader-for-codeigniter/
Posted 22 August 2012 - 12:33 PM