⚠ 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_n_n doesn't work if the priority_field_table_relation is equal to primary_key_alias_to_this_table or primary_key_alias_to_selection_table



goFrendiAsgard
  • profile picture
  • Member

Posted 24 August 2012 - 04:17 AM

This is probably a bug, not a big deal, just a bit annoying.
Maybe it should be added as "known issue"

For instance, this is work:

$crud->set_relation_n_n('members',
'schoolyear_class_member', 'student',
'schoolyear_class_id', 'student_id', '{code} - {name}',
'id', $where);

While this is not:

$crud->set_relation_n_n('members',
'schoolyear_class_member', 'student',
'schoolyear_class_id', 'student_id', '{code} - {name}',
'student_id', $where);



This might be solved by make alias of student_id.
Actually, I want to help fixing this, but right now I don't have much time left :P

[b]EDIT:[/b]
This is confirmed as not bug. Read the posts below

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

Posted 16 September 2012 - 08:54 AM

Hello [member='goFrendiAsgard'] and sorry for the delayed answer,

Actually it doesn't make sense to work like this: both "id" and "student_id" is wrong. The thing is that this field is a priority field and not an ordering field. This simply means that when you drag the item the ordering is changing to :0,1,2,3,4,5 . So it is a bad logic to add "id" or "student_id".Imagine that suddendly you will have as student_id 0,1,2,3,4 that it doesn't make any sense. So I don't think that this is a bug.

Cheers
Johnny

goFrendiAsgard
  • profile picture
  • Member

Posted 17 September 2012 - 02:47 AM

[quote name='web-johnny' timestamp='1347785650' post='3458']
Hello [member='goFrendiAsgard'] and sorry for the delayed answer,

Actually it doesn't make sense to work like this: both "id" and "student_id" is wrong. The thing is that this field is a priority field and not an ordering field. This simply means that when you drag the item the ordering is changing to :0,1,2,3,4,5 . So it is a bad logic to add "id" or "student_id".Imagine that suddendly you will have as student_id 0,1,2,3,4 that it doesn't make any sense. So I don't think that this is a bug.

Cheers
Johnny
[/quote]

Thanks for your response. And thanks to confirm it as not bug.
I still don't get it clear. What is the different between "ordering field" and "priority field"?
Is there any more explanation.

thanks :)

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

Posted 17 September 2012 - 23:35 PM

This is simple, let's say that we have this example: http://www.grocerycr..._a_relation_n_n . So in our case the ordering that we actually want is per fullname (default) . If we wanted for example to order it by last_update with the help of your contribution we will do this:

$crud->set_relation_n_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'fullname','priority',null,'last_update');

but if don't want to actually order it by priority we can simply do this:

$crud->set_relation_n_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'fullname',null,null,'last_update');


and NOT this:
$crud->set_relation_n_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'fullname','actor_id',null,'last_update');

The above code is wrong, as the "priority" field is the field that you add only if you want to reorder the values and there is a specific field for this.

For example if we use the priority field like this:

$crud->set_relation_n_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'fullname','priority',null,'last_update');

we will have this:
[attachment=287:2012-09-18_003209.png]

but if we add as null the priority field the user will not be able to change the ordering and also the interface is also changed to not confuse the users. So in our case if you have this:

$crud->set_relation_n_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'fullname',null,null,'last_update');

you will have something similar to this as a result:
[attachment=288:2012-09-18_003309.png]

Cheers
Johnny

goFrendiAsgard
  • profile picture
  • Member

Posted 18 September 2012 - 00:30 AM

Ok, I think I've just get it. Priority field is something in relation table, while ordering field is something is selection table.
Thanks to make it clear :)