• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

how to copy a field's value

rongame

Member
hi

i have a form and i added a list below it.

both is working fine.

my question is how to add a button that will copy a fields value, copying data from the list to the form.

what i tried is to add a js plugin in the list. i tried to use the js code below but it does not work.

records_field___empty_id = database join element that is empty. this is in the form
user_prle___datatocopy = field element that contains the value to copy, this is in the list

Code:
$('records_field___empty_id').value = $('user_prle___datatocopy').getValue();

BTW, im only copying 1 field to another. not the entire row

thank you
 
Assuming you are only using the JS button on one row at a time ...

In your JS, you have two objects available, ids and rows. The ids object holds all the selected rowids. The rows object holds all the row data, indexed by rowid. So in your case, there will only be one 'ids', ids[0], which will have the rowid of the row you used the JS button on. So you can then use that to index rows, like rows[ids[0]]. So your 'datattocopy' is then rows[ids[0]].user_prle___datatocopy.

Then you need to find the form object, and set the data on that. To get the form object is Fabrik.getBlock('form_X'), where X is the numeric form id. That object then contains the formElements array, and you'll use the update() method on the element you want to set. So ...

Code:
Fabrik.getBlock('form_123').formElement.get('records_field___empty_id').update(rows[ids[0]].user_prle___datatocopy);

Replace 123 with you form ID.

You may need to use user_prle___datatocopy_raw, depending on what element type it is.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top