⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Populating dropdown from another table



Mrinal Rajpurohit
  • profile picture
  • Member

Posted 20 August 2012 - 18:37 PM

Hi,
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.

noskov.biz
  • profile picture
  • Member

Posted 20 August 2012 - 19:46 PM

Hi, Mrinal Rajpurohit and welcome to the forum!
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!

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 20 August 2012 - 19:59 PM

Hello from me too,

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

Mrinal Rajpurohit
  • profile picture
  • Member

Posted 20 August 2012 - 20:04 PM

yes it worked. thanks.

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?

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 20 August 2012 - 20:30 PM

This functionality is default at the new version of 1.3 . You can either:
[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' />";
}

imag
  • profile picture
  • Member

Posted 21 August 2012 - 12:33 PM

web-johnny

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?

Osama
  • profile picture
  • Member

Posted 22 August 2012 - 08:51 AM

@ web-johnny

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 ! :D

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 22 August 2012 - 12:07 PM

Hello [member='Osama'] and welcome to the forum,

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/

Osama
  • profile picture
  • Member

Posted 22 August 2012 - 12:33 PM

Thanks Web-Johny You are The Best :D I'll Have a Try and Tell You :rolleyes: