⚠ 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

Set Relation to the Same Table



mrtakdnz
  • profile picture
  • Member

Posted 15 August 2012 - 22:47 PM

Hi, i try to set a relation into the same table. everything is ok but when listed the itmes the column which name is category_title display as blank.
i try to change it's name as ->columns('efe_category.category_title as ctitle') or something like this but it didnt fix anything.

Thanks in advance.


function category($cat_type) {

$this->crud->set_table('efe_category')
->set_subject('Kategori')

->columns('category_title')
->fields('category_inherit','category_title','category_type')

->display_as('category_title','Başlık')
//->display_as('category_','Başlık')
->display_as('category_inherit','Ãœst Kategori')

->change_field_type('category_type','hidden',$cat_type)

->where('efe_category.category_type',$cat_type);

$this->crud->set_relation('category_inherit','efe_category','category_title',array('category_type' => $cat_type));

$this->vdata['crud'] = $this->crud->render();
$this->_view('crud_view');

}


Table Structure:


CREATE TABLE `wf_category` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`category_inherit` int(11) NOT NULL DEFAULT '0',
`category_type` varchar(120) COLLATE utf8_unicode_ci NOT NULL,
`category_title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

Posted 16 August 2012 - 06:19 AM

Hmmm it seems that this is a bug. I will check it deeper when I will find some time so to be fixed for version 1.3 . Until then if I find any work-around for this I will inform you.

Thanks for sharing.

[b]Update: [/b]Probably the problem is that you have the same name `category_title` . I know that this is correct for you but just for now you can change the category_title to efe_category_title just to see if this it works for you.

mrtakdnz
  • profile picture
  • Member

Posted 16 August 2012 - 08:05 AM

How can i change the category_title to efe_category_title? form DB? is there any way to rename column name like
->columns('category_title AS efe_category_title')
something like this?

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

Posted 16 August 2012 - 08:52 AM

I am sorry but I think it will not work if you do something like that. If you cannot change the field from the db that's ok. I wanted just to check if this will work for you (just to check that the field name is the case). I will take a look at this but I was sure that this bug was fixed :mellow: . Do you have the latest version 1.2.3? What Codeigniter version do you use? I will inform you for any changes.

Cheers
Johnny

mrtakdnz
  • profile picture
  • Member

Posted 16 August 2012 - 09:00 AM

yeah, i'll have v.1.2.3. oh another q. should i use the nightly build from github for my clients? is it safe to use. i know it's kinda beta release but it has many improvements (like better look and ckeditor).

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

Posted 16 August 2012 - 17:14 PM

I think the nightly build is fine as far as I tested. The only thing that actually doesn't work is the export and the print button in flexigrid theme. So you can just go to assets/grocery_crud/themes/flexigrid/views/list_template.php and remove the export and print button for now (delete the lines 51-68). I don't think that you will have another problem. The good thing about grocery CRUD is that the most of the times is "What You See Is What You Get" so just test the Add,Edit and Delete and if it works fine then probably everything is working fine.

P.S. The problem with the [color=#282828][font=helvetica, arial, sans-serif]category_title will still remain at the nightly version.[/font][/color]

mrtakdnz
  • profile picture
  • Member

Posted 16 August 2012 - 17:23 PM

Ok, thanks for the help. I have to lie to my clients for now or i have to find another solution for this. By the way i want to make suggestion but i cannot find the right category in this forum. :)

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

Posted 16 August 2012 - 19:42 PM

I hope the bug will be fixed before you have to lie to your clients. I will try to have a normal bug fix or at least a work-around for your problem.

Cheers
Johnny

mrtakdnz
  • profile picture
  • Member

Posted 16 August 2012 - 19:48 PM

I'm so appreciated, thanks much Johnny.

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

Posted 17 August 2012 - 06:43 AM

Something last. Can you please post the structure of your 2 tables so I can reproduce the bug?
According to this:

function category($cat_type) {

$this->crud->set_table('efe_category')
->set_subject('Kategori')

->columns('category_title')
->fields('category_inherit','category_title','category_type')

->display_as('category_title','Başlık')
//->display_as('category_','Başlık')
->display_as('category_inherit','Ãœst Kategori')

->change_field_type('category_type','hidden',$cat_type)

->where('efe_category.category_type',$cat_type);

$this->crud->set_relation('category_inherit','efe_category','category_title',array('category_type' => $cat_type));

$this->vdata['crud'] = $this->crud->render();
$this->_view('crud_view');

}


I need the table [i]efe_category[/i] and [i]category_inherit[/i]

Thanks

Kindest Regards
Johnny

mrtakdnz
  • profile picture
  • Member

Posted 15 September 2012 - 23:28 PM

Problem solved with 1.3.1 version. Thanks much...