⚠ 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

Priority Field Relation in the set_relation_n_n function



Cèsar Martí

Cèsar Martí
  • profile picture
  • Member

Posted 14 March 2012 - 12:50 PM

Hi guys!

I need to do something like the 'Actors' example from here http://www.grocerycrud.com/examples/set_a_relation_n_n. Of course, I've been reading the forum posts of the set_relation_n_n fucntion and the documentation from here http://www.grocerycrud.com/documentation/options_functions/set_relation_n_n

My doubt is about the Priority Field Relation in the Ralation Table. What is it suposed to be in that field? I see it've to be an INT(11) in the database table. But, what should be the data in that field? In the 'Actors' example, why isn't be enough with the relation between films and actors? Why not just 'film_id' and 'actor_id'? Why this 'priority' field?

Any kind of help will be appreciate. Thanks a milion.

web-johnny

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

Posted 14 March 2012 - 18:49 PM

The priority field is not a required filed. So if you want also to sort your multiple select you can do it by just adding the last segment (priority field). For example you can simply have:

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

without any problem.

The priority is if you want to have a drag-n-drop to change the priority like the image: [attachment=66:drag-and-drop.png]

Cèsar Martí

Cèsar Martí
  • profile picture
  • Member

Posted 15 March 2012 - 08:32 AM

I see. I'm gonna test it right now. Thanks Johnny.

Hoergold2

Hoergold2
  • profile picture
  • Member

Posted 19 September 2012 - 15:13 PM

Interesting: I asked myself the same question (what is this field for). As I understood it it comes from a special use case and does add some nice funtionality (drag'n'drop to reorder the persons). But allow me the suggestion that it could be explained also in the API - maybe one time very clear for all..

Thanks,
Martin