question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom Button not working in the Rendering/Embedding

See original GitHub issue

Hi, i have a custom button , which clear the values / reset the particular component. i.e. data.firstname='';

It works fine inside the Form.io Online / Open source . But when it comes to the Rendering/Embedding side , it wont work at all. Even there is no error in the console. I tired this on the Form.io Online portal , and i found out the same problem. It works fine when we view the form in the Form Viewer , but when we use the single line script tag inside the HTML , its not working .

<script src="https://unpkg.com/formiojs@latest/dist/formio.embed.js?src=https://qfeuvqlfrsmdign.form.io/message"></script> I think the embed.js has missing some functions . Any ways to solve this Issue.

And i wanted to know much more about the Actions in the Button , Like Event , Auth etc. I didn’t find much more information about these usage . Any information provided would be a useful.

Thank You

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
travistcommented, Oct 31, 2018

There are several issues that arise when allowing one component to alter the state of other components (as it is suggested here).

1.) The state of any component is mutable by other components and conflicts in state changes can cause erratic behavior such as when one component sets the state of one component to one value while another component sets it to a different value.

2.) Performance is negatively affected where all button events would need to trigger global form redraw since it would be hard to determine from reading custom code which components may be affected by the change.

We are deliberately making this not supported via setting the data attribute. However, there is a way to “break the rules” if you insist. In every code execution, we do provide the instance variable which points to the component instance. Within the instance you have access to the root form object, which is the most top-level component of a rendered from. From that perspective, you can then get the component you wish to alter, and set the value directly. Something like this may work.

Use at your own risk!!

var component = instance.root.getComponent('componentA');
component.setValue('testing');
1reaction
wag110894commented, Oct 30, 2018

Hello Pradeep,

You cannot use a button using custom javascript to change another component’s value in our new renderer. This is by design. You can use a button event and field logic to set the value.

Here is an example of this: http://formio.github.io/formio.js/app/examples/fieldLogic.html Here is schema for Field Logic: https://github.com/formio/formio.js/wiki/Field-Logic-Schema Please let me know if you have any further questions or concerns.

Thanks,

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom button rendering html - Salesforce Developers
Here is my problem. I have a custom boject linked to CASE called RASolution. They are linked by a Lookup Relationship which Creates...
Read more >
apex - Embedded Visualforce Page causing custom buttons to ...
When embedding Visualforce pages in layouts the whole page, including everything on it is displayed in that section of the layout.
Read more >
Custom button icon (Image Fit - Fill) rendering is...
Hello. Ever since we updated our power bi desktop, we are seeing permananet rendering issues in the custom button icon when using the...
Read more >
Embed image in a <button> element - html - Stack Overflow
Update: What actually happens, I think, is a margin problem. I get a two pixel margin, so the background image is going out...
Read more >
Troubleshooting Embedding - Observable
The reactive variable width refers to the clientWidth of the entire document body. That means that if you use the Runtime to render...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found