Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Make webform embeddable #25598

Merged
merged 2 commits into from
Mar 22, 2024

Conversation

surajshetty3416
Copy link
Member

@surajshetty3416 surajshetty3416 commented Mar 22, 2024

This is the simplest implementation to make web forms embeddable (might require more changes later on). Now all the unnecessary elements from the web form will be hidden if it is rendered within Iframe.

Usage:

Screen.Recording.2024-03-22.at.3.00.16.PM.mov

closes: frappe/builder#114
Suggestion by @rmehta

- If Web Form is rendered in Iframe all unnecessary elements from the web form view is hidden
@surajshetty3416 surajshetty3416 requested a review from a team as a code owner March 22, 2024 09:41
@surajshetty3416 surajshetty3416 requested review from ankush and removed request for a team March 22, 2024 09:41
@cogk
Copy link
Contributor

cogk commented Mar 22, 2024

Ah very nice!

I did have the same idea earlier this year, my prototype was more "server-side" and worked on all pages (which might not be desired/possible):

# frappe/templates/web.html

{% set in_iframe = ("_iframe" in frappe.form_dict) %}

{% if in_iframe %}{% set show_sidebar = False %}{% endif %}
{% block banner %}{% if not in_iframe %}{{ super() }}{% endif %}{% endblock %}
{% block navbar %}{% if not in_iframe %}{{ super() }}{% endif %}{% endblock %}
{% block footer %}{% if not in_iframe %}{{ super() }}{% endif %}{% endblock %}

@batonac
Copy link
Contributor

batonac commented Mar 22, 2024

Nice start on webform integration, and good feature.

Iframes have lots of inherent paper cuts, not the least of which are the inability to redirect the parent doc and the lack of dynamic resize when showing/hidden fields and sections. It would sure be nice to have a webform block in builder that incorporates the necessary code to render and run the form. Obviously, this is wistful thinking in the short term since there are a variety of inherent challenges such as styling that need addressed, so I'm super happy to see this happening in the meantime.

@cogk
Copy link
Contributor

cogk commented Mar 22, 2024

the inability to redirect the parent doc and the lack of dynamic resize

Yesterday I read these interesting bits of documentation about iframe, resizing, and inter-frame communication (message DOM event).

@batonac
Copy link
Contributor

batonac commented Mar 22, 2024

iframe, resizing, and inter-frame communication (message DOM event).

That could be really cool, especially in the short term. Another challenge here is styling and modern framework tooling in general. Frappe core still uses Bootstrap 3 and Frappe-specific styling. Builder is trying to break out of that legacy and allow new possibilities.

Long term, a builder style book which incorporates form styling would be the best-case scenario IMO.

@surajshetty3416 surajshetty3416 merged commit d12123f into frappe:develop Mar 22, 2024
23 of 24 checks passed
@surajshetty3416 surajshetty3416 deleted the embedable-webform branch March 22, 2024 16:53
@sudhegan
Copy link

sudhegan commented Apr 6, 2024

is this going to released in upcoming version 15 release??

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 2024
@surajshetty3416
Copy link
Member Author

@Mergifyio backport version-15

@surajshetty3416 surajshetty3416 added the backport version-15-hotfix Backport the PR to v15 label May 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport version-15-hotfix Backport the PR to v15
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Embed Web Form in Builder
4 participants