Open Form With JavaScript (PopUp/Modal)

Don't use $(). Use the Fabrik element object.

Fabrik.getBlock('form_X').formElements.get('yourtable___yourelement').getValue()

Replace X with your form's numeric ID, and the element full name.



Sent from my HTC6545LVW using Tapatalk

Hi Cheesegrits!!! I already did the subscription!

It's working the way I want! The only drawback is that clicking the button opens the form with the error (It was impossible to find this record.) : https://prnt.sc/hv2ec5

Could you help me find the solution?
 
I tried it. But you didn't post the URL which is used to open the form. With the URL it is possible to see, if perhaps the id of the record to be loaded is wrong. If you do not want to post the URL here for security reasons only post the local part of it. If any personal information is in the URL (e. g. names) just depersonalise them. But there should be only record ids.
 
I tried it. But you didn't post the URL which is used to open the form. With the URL it is possible to see, if perhaps the id of the record to be loaded is wrong. If you do not want to post the URL here for security reasons only post the local part of it. If any personal information is in the URL (e. g. names) just depersonalise them. But there should be only record ids.

Hi Burghard,

How do I see the URL being called? I have already inspected the element in Chrome and Firefox and do not know how to see ...

However in the button I have:

var url = 'index.php?option=com_fabrik&view=form&formid=34&tmpl=component&ajax=1&format=partial';
url = url + '&idassessorurl=' + $('tb_contactos_geral___id').getValue();

Fabrik.getWindow({
id: 'some-unique-id',
contentURL: url,
loadMethod: 'xhr',
title: 'Enviar SMS',
height: '50%',
width: '50%'
});
 
You can view the URL in the source code of the resulting HTML page. Just right click in your window and select "view source" (or similar) from the context menu. Look for your link.

cheesegrit wrote to use the URL with the following components:
Code:
let url= 'index.php?option=com_fabrik'
+ '&view=form'
+ '&formid=123'
+ '&rowid=321'   // <-- don't miss the rowid!
                 // it is the id of the record to load into the form
+ '&tmpl=component'
+ '&ajax=1'      // <-- you missed this, too!
+ '&format=partial';
but you missed the rowid in your code to form the URL. You must supply a rowid in the URL in order to let the record be loaded into the form.
 
You can view the URL in the source code of the resulting HTML page. Just right click in your window and select "view source" (or similar) from the context menu. Look for your link.

cheesegrit wrote to use the URL with the following components:
Code:
let url= 'index.php?option=com_fabrik'
+ '&view=form'
+ '&formid=123'
+ '&rowid=321'   // <-- don't miss the rowid!
                 // it is the id of the record to load into the form
+ '&tmpl=component'
+ '&ajax=1'      // <-- you missed this, too!
+ '&format=partial';
but you missed the rowid in your code to form the URL. You must supply a rowid in the URL in order to let the record be loaded into the form.

Hi Burghard,

I put this code:

var url= 'index.php?option=com_fabrik'
+ '&view=form'
+ '&formid=34'
+ '&rowid=3'
+ '&tmpl=component'
+ '&ajax=1'
+ '&format=partial';
+ '&idassessorurl=' + $('tb_contactos_geral___id').getValue();

Because I need to pass the value of the field: tb_contactos_geral___id, and it continues to give error.
 
  1. Which error is raised?
  2. Does the error occur if you do not pass the idasessionurl parameter?
  3. Does the record with the rowid=3 exist?
  4. Is the record with the rowid=3 editable for you in the perspective of fabrik?
 
  1. Which error is raised?
  2. Does the error occur if you do not pass the idasessionurl parameter?
  3. Does the record with the rowid=3 exist?
  4. Is the record with the rowid=3 editable for you in the perspective of fabrik?

Hi Burghard!

If you put the "rowid" in the URL, the error no longer appears! But why do I have to use "rowid" in the URL?
This form that opens when clicking the button, may not record the records, I just want to collect fields to then run a script in php ...

But even if you want to record the records in the DB, it will create a new record. Why are you looking for a record?
 
tiagovareta said:
What I intend is: "It is also possible to show popups with related data from inside a form."
The rowid in the url tells the server side of fabrik to load a record out of the database and ask the client side to load it into the popped up form.
It is not clear what you mean with:
tiagovareta said:
This form ... may not record the records, I just want to collect fields to then run a script in php ...
The form does not "record records". It only displays a record, enabling the user to edit it. Do you want to create a new record which is related to the one displayed in the parent form?
Or is the data you want to display in the form out of the same record and you want to divide the data into two forms? In the latter case may be you want to use a multi page form?
 
The rowid in the url tells the server side of fabrik to load a record out of the database and ask the client side to load it into the popped up form.
It is not clear what you mean with:

The form does not "record records". It only displays a record, enabling the user to edit it. Do you want to create a new record which is related to the one displayed in the parent form?
Or is the data you want to display in the form out of the same record and you want to divide the data into two forms? In the latter case may be you want to use a multi page form?

Hi Burghard!

Thanks for all the help! I put rowid = 0, and it works without error! Have problems use 0?
Thank you!
 
You still need rowid on a form view URL, even if it doesn't record in the database. Leaving it blank or using 0 should work. The form input is needed in the router code (the extension specific code that takes what is on the URL after option=com_foo, and figures out what task to run). And that happens long before the form specific code (that knows whether the form writes to the database or not) runs.

-- hugh
 
You still need rowid on a form view URL, even if it doesn't record in the database. Leaving it blank or using 0 should work. The form input is needed in the router code (the extension specific code that takes what is on the URL after option=com_foo, and figures out what task to run). And that happens long before the form specific code (that knows whether the form writes to the database or not) runs.

-- hugh

Hi Cheesegrits!!!

Thanks for the clarification! I put 0 and it works.
 
I am trying to use this link. I still can't match ids, but this is a minor issue right now. Now I find the problem that opens the form in modal but in addition to this opens the link also in another window ... how can I solve?
upload_2022-1-10_15-13-39.png
upload_2022-1-10_15-15-37.png
 
How do you open the link? Do you have some custom button with click event code somewhere?
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top