Welcome, Guest
Username: Password: Remember me

TOPIC: Add item from Foreign key field

Add item from Foreign key field 16 Sep 2014 09:11 #12631

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 16
We now have ajax...
We now have modals...

Is it now possible to have an 'ADD x' button next to a foreign field that will popup a modal window allowing you too add a new item to the foreign table.

Example

I have a table of people
I have a table of skills

I am adding a new person who has a skill not currently in the skill table, so on my foreign key dropdown I need to add a new skill, I click the ADD button next to the skill drop down, modal pops up, add the new skill, save it and ajax refreshes the select box

is this possible using the basic code, and is it possible to add something like this automatically to the builder
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla
The administrator has disabled public write access.

Add item from Foreign key field 16 Sep 2014 13:36 #12640

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
You hit in the middle of the target. Well done !

Yes, I would love it, but the most complex part comes when the item is picked up, then we need to refresh the list without reloading the whole parent, wich makes the problem more complex.

I will not investigate in that for the moment, because such combo list must be created with ajax support, and it make the code more complex (new view)
Well it is possible I propose it, but not as a priority for the moment. I recognize it is amazing and I would love it. We ALL have been in such situaltion many times. Close the page, go to another section, create the item, come back in our form (sometimes with lost of datas because we couldn't save the first try) etc...

I am planning another way of doing. I would like not to rewrite always the code for each ajax use.
In future, ajax will be handled inside a kind of mini framework wich 'consume' the datas.

In order to not duplicate the code between JS and PHP, your datas and filters, and all model structure (and views) will be handled by XML, and shared between JS and PHP. It is the FoF approch (Rapid Application Developpement).

So, todo Ajax in a Joomla native way is not efficient and long way. Ok for a simple request, but using controls, and tables, etc... no way. It is too heavy to always send all HTML structure, and JSON result works great, but need advanced coding experience for making something with it.

Cook will always be open for making such practives, but in future (next year I guess), your component structure will be drastically simplificated with RAD concepts. So JS will be able to 'consume' datas, and also beeing able to interface easier your applications together even when they are on different servers.

If you propose your code, I can implement it, and extend your account.
The work todo is:
1. Create a new ajax entry in the VIEW file of the concerned table (outputing a JDom combo)
2. Creating a new JDom class for handling the HTML and JS code for that functionality (for combo only, or for any other kind)
3. Connect the result returned by the modal with the call of corresponding AJAX call to refresh the control.


Also to add something to the debate, for doing this in pure JS (no modals), it would be directly a small form appearing on the top (wich is not a call of index.php), but simply a dynamic JS script, and send it transparently with a spinner, and if the result is accepted, then no need to make another heavy call to return all existing datas + the new created (wrapped in HTML....) ouch...
I am tired of this way, and even if many Joomla coders don't necessary deals with lot of JS, we will need to learn a little bit to code the JS side.
I mean this will be offered in option for those who like to go on with ajax.
It will be 'Full ajax' application if we want it will be possible.
It is a long time I have this in mind, and for the moment I still search a good JS framework to start with that. (don't need to reinvent the wheel)

Thanks for reading.
It is long answer because you hit in the center of my preoccupation and choice for next move.
I should make a poll.
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.082 seconds

Get Started