Welcome, Guest
Username: Password: Remember me

TOPIC: Can a modal popup populate a parent form?

Can a modal popup populate a parent form? 24 Sep 2015 05:51 #13485

  • jonathanbell
  • jonathanbell's Avatar
  • Offline
  • Premium Member
  • Posts: 147
  • Thank you received: 5
  • Karma: 1
Hi, as I'm still learning code and I was wondering if it is possible to open a modal window from a an edit screen (Parent) and populate a set field on the parent with what ever you selected from the <collection view> modal pop up?

Has anyone got any example script of this working? This is rather than a drop down list on the parent form and solves my problem of being able to get data from another component. I have seen a few javascript examples but not even sure if they would work.

Sorry this should have gone into the coding in your component section.. I pushed submit way to soon. :(
Last Edit: 24 Sep 2015 05:52 by jonathanbell. Reason: appoligising for again putting this in the wrong section on the forum..:(
The administrator has disabled public write access.

Can a modal popup populate a parent form? 24 Sep 2015 11:05 #13486

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 16
This is one of things that was requested as a feature, and would require an AJAX refresh of the field on save when you go back to the main form, so you would need to locate the AJAX trigger and fire it with the save function in the model of the modal window table. (its easy to say / guess how to do it, in practise however..)

I will be interested to see if this is now an easier thing for the Chef to cook with his new framework and FoF as a function

I have not tried to get it working myself as always found a work around and its always been a desired function, never a necessity for me
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla
The administrator has disabled public write access.
The following user(s) said Thank You: jonathanbell

Can a modal popup populate a parent form? 24 Sep 2015 11:23 #13487

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Yes, in fact, it would be great.

There is two things:
1. Modal picker to load a simple item. (I could eventually propose it, it is on the roadmap, easy to do)
2. Modal to add an item in a list + select it.

For 1, you don't need AJAX, just JS to select the correct value.
For 2, you need AJAX to refresh the list including the new item, but you can also do it in JS only, with more code.

Both features needs to be coded by hand.
The revolution for that will come with Angular JS.
FOF is not dealing with that at the moment.
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: jonathanbell

Can a modal popup populate a parent form? 25 Sep 2015 07:32 #13503

  • jonathanbell
  • jonathanbell's Avatar
  • Offline
  • Premium Member
  • Posts: 147
  • Thank you received: 5
  • Karma: 1
Thanks Chef and Morgan, I have found some interesting examples on a number of coding forums. So I am going to give it a go by adding some JS functionality to a really simple component based on the examples. Fingers crossed I get a working example. If it works , do you want me to post it or check it before I do?

Happy building.

Cheers

Jonathan
The administrator has disabled public write access.

Can a modal popup populate a parent form? 25 Sep 2015 10:00 #13504

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Cool !
Yes of course first you have to make it working before to share it.
And then if it is good, I will introduce it in the component.
Coding is now a piece of cake
The administrator has disabled public write access.

Can a modal popup populate a parent form? 04 Oct 2015 02:11 #13562

  • jonathanbell
  • jonathanbell's Avatar
  • Offline
  • Premium Member
  • Posts: 147
  • Thank you received: 5
  • Karma: 1
Oh well, this was somewhat harder than I imagined. Still working on a work round with Java. Will continue to look at options to make this work. :oops:
The administrator has disabled public write access.

Can a modal popup populate a parent form? 05 Oct 2015 07:50 #13565

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
Hi,

Is what you mean something like creating a menu-item?
Click "Select" for "Menu Item Type *" -> modal popup with menutypes -> choose -> type is updated
The administrator has disabled public write access.

Can a modal popup populate a parent form? 05 Oct 2015 08:11 #13566

  • jonathanbell
  • jonathanbell's Avatar
  • Offline
  • Premium Member
  • Posts: 147
  • Thank you received: 5
  • Karma: 1
More like a pop up or preferably a modal to populate a selected field in the parent.

I have got the parent form to open a a form from another component as a modal. On the other form it is a collection (list). I have placed a button into the collection to call a java script function. So based on what line you have selected it would populate a preset field on the Parent.

I know how to make a button populate a field on the parent: when the button is on the same page. Thats reasonably simple as I have used this for a risk matrix.
I have tried window.open and its options to try just using a popup rather than modal. which works just fine on an html page, but for some reason the javascript does nothing when trying within my component and it is driving me "nuts"

I'll post the scripting I have tried to date tomorrow. Have an early start in the morning...
The administrator has disabled public write access.

Can a modal popup populate a parent form? 05 Oct 2015 09:13 #13567

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Ok, I understand, you simply would like to populate a DYNAMIC variable.
The same popup can populate different inputs (using the one 'selected', you mean 'focus' ?)

Well, I think that is possible because the modal can recieve it in parameter of the url.
Check the FOF build, I have created such a field for FOF. -> ModalPicker.
Coding is now a piece of cake
The administrator has disabled public write access.

Can a modal popup populate a parent form? 06 Oct 2015 17:49 #13574

  • polsl
  • polsl's Avatar
  • Offline
  • New Member
  • Posts: 8
  • Karma: 0
I was checking this topic from time to time, because I was sure the whole idea was different. Wouldn't it be great to add "Other" button as the first/last option for combo field? That should allow the visitor to define some new value for combo (based on other table).
If the other table had more fields than just a key and a name, it would be most reasonable to open the form for the other table in modal box. That solution would require saving a new item in the modal box and retrieving the new key and appropriate field (label) for combo in the parent form.
Maybe you are planning to include similar funtionality in next update :) ?
The administrator has disabled public write access.

Can a modal popup populate a parent form? 12 Oct 2015 01:34 #13585

  • jonathanbell
  • jonathanbell's Avatar
  • Offline
  • Premium Member
  • Posts: 147
  • Thank you received: 5
  • Karma: 1
Yup got that working. Have button next to field in my java I have it name the field and send this to the modal or popup window.

At the moment I am working with a popup window... With the following extended Java Script for easy reading... This is called by : <input type="button" class="btn btn-success" value="Select" onclick="Apopup()">

<script type="text/javascript">
function Apopup() {
//longer script to ensure you are placing the right variables in to open the correct page: Can open popup for another component.
var compoption="com_popuptry"; //The component you are pointing to
var compview="stuff";// The view in the compenent
var complayout="stuff";//which layout in the view you are using
var compfield="jform_my_stuff"//The field you want the data to go to
var w=800;//width of the window
var h=600;//height of the window
var title="My Stuff Options"// title of window
var left= (screen.width/2)-(w/2);// find horisontal center
var top= (screen.height/2)-(h/2);//find vertical center
//combine strings to make url for window opening
var url="/index.php?option="+compoption+"&view="+compview+"&layout="+complayout+"&fromfield="+compfield+"tmpl=component"
var popup=window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes, width='+w+', height='+h+', top='+top+', left='+left);//open popup
popup.focus();
}
</script>
The administrator has disabled public write access.

Can a modal popup populate a parent form? 12 Oct 2015 10:57 #13586

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 16
For easy reading, if you can drag / select all your code before publishing the post.. and then click the 'Code Display' icon in the tool bar (looks like <> )

That way your code is easier to read.. i,.e
<input type="button" class="btn btn-success" value="Select" onclick="Apopup()">
<script type="text/javascript">
function Apopup() {
//longer script to ensure you are placing the right variables in to open the correct page: Can open popup for another component.
var compoption="com_popuptry"; //The component you are pointing to
var compview="stuff";// The view in the compenent
var complayout="stuff";//which layout in the view you are using
var compfield="jform_my_stuff"//The field you want the data to go to
var w=800;//width of the window
var h=600;//height of the window
var title="My Stuff Options"// title of window
var left= (screen.width/2)-(w/2);// find horisontal center
var top= (screen.height/2)-(h/2);//find vertical center
//combine strings to make url for window opening
var url="/index.php?option="+compoption+"&view="+compview+"&layout="+complayout+"&fromfield="+compfield+"tmpl=component"
var popup=window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes, width='+w+', height='+h+', top='+top+', left='+left);//open popup
popup.focus();
}
</script>
Morgan Leecy MCSE

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

Can a modal popup populate a parent form? 09 Nov 2015 19:48 #13669

  • jeisonsan
  • jeisonsan's Avatar
  • Offline
  • Junior Member
  • Posts: 25
  • Karma: 0
I do this by passing the url to get (getVar)
The administrator has disabled public write access.
Time to create page: 0.138 seconds

Get Started