Welcome, Guest
Username: Password: Remember me

TOPIC: About m to n relations - add button inside form

About m to n relations - add button inside form 01 Feb 2013 14:24 #6606

  • dieda1821
  • dieda1821's Avatar
  • Offline
  • Senior Member
  • Posts: 53
  • Thank you received: 2
  • Karma: 4
Hi,

I have seen the "travel" tutorial and I'd like to ask an info.

As far as I understand the "many to many" third table is filled manually by means of a dedicated layout.
Would it be possible to insert the relation directly inside the traveler form, by means of an "Add"-"Delete" button ?

That is, let's say I have already filled my "City" table. I am now filling my "Traveler" table, and, while I am inserting the info related to one traveler (name, surname, ecc...) I would like to find a field "Has travelled to" where I can have a drop-down and choose a city, than by clicking "Add" a second drop-down should appear, and so on...
When I save, for each drop-down, a row in the table "Travels" should be created (id, traveler_id, city_id).

In this way, if an item has different many-to-many relations, these could be seen inside the same layout, without having to do the data entry inside dedicated layouts.

Can this be done (I mean, relatively easily) ?

Thanks for the assistance

Elena
The administrator has disabled public write access.

Re: About m to n relations - add button inside form 01 Feb 2013 14:27 #6607

  • dieda1821
  • dieda1821's Avatar
  • Offline
  • Senior Member
  • Posts: 53
  • Thank you received: 2
  • Karma: 4
I forgot to add that, in this way, the "Travels" table could eventually be hidden (that is, it exists and is filled by data, but is not linked to any layout if this is not considered useful for the user).

Elena
The administrator has disabled public write access.

Re: About m to n relations - add button inside form 01 Feb 2013 15:26 #6609

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Hi Elena and welcome to Cook!

What you propose is very much accomplishable with some post-cook coding.
  1. You could use jQuery (or another JS library if you like) to achieve the dynamic 'add'/'delete' tasks to your form - See this topic that goes through some jQuery in forms. It's not what you're trying to achieve but the same principle - using jQuery in forms: www.j-cook.pro/forum/35-jquery/4481-show...ds-in-front-end-form
  2. Call an instance of your second form into your 'Traveller' edit form and adapt - See link. Some things may differ - for instance, example is using JDom for form inputs instead of JForms - however, it should get you started: www.j-cook.pro/forum/9-coding-inside-you...les-in-one-view#1882


Hope it helps,

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
Last Edit: 01 Feb 2013 15:26 by JoomGuy.
The administrator has disabled public write access.

Re: About m to n relations - add button inside form 03 Feb 2013 12:40 #6614

  • dieda1821
  • dieda1821's Avatar
  • Offline
  • Senior Member
  • Posts: 53
  • Thank you received: 2
  • Karma: 4
Thanks, I will try and let you know.

Sorry for the newbie question: once I download my job and start customizing it, am I supposed to go on outside Cook, or is there the chance of uploading my "cook-born" customized component to modify it (e.g. adding a table, a field, ecc...) while maintaining the modifications ?
The administrator has disabled public write access.

Re: About m to n relations - add button inside form 03 Feb 2013 12:49 #6615

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Hi Elena,

Sorry, there is no such mechanism for that and therefore, one must merge any cook changes into modified local projects. The best way is to use an IDE as most of them have a local file history that allow comparison between altered files, merging and so on.

Also, a lot can be said for hanging on until the very last moment to make any local customisations. That way, any 'core' changes you have to make to your component will be minimal.

There is a discussion about IDEs here that may be useful: www.j-cook.pro/forum/33-developper-resso...-for-php-development

Personally, and speaking as someone who is quite new to IDEs, I've found Aptana very useful indeed!

Hope it helps!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: About m to n relations - add button inside form 03 Feb 2013 20:03 #6624

  • dieda1821
  • dieda1821's Avatar
  • Offline
  • Senior Member
  • Posts: 53
  • Thank you received: 2
  • Karma: 4
Thanks Gez,

I am downloading Aptana (nevere tried it before).

I will try to go as further as I can inside Cook, so to reach a "Cook last version" to customize outside.

Elena
The administrator has disabled public write access.
Time to create page: 0.125 seconds

Get Started