kjac / FormEditor

A form builder editor for Umbraco 7 - let your editors build forms easily with this free package.
MIT License
99 stars 42 forks source link

Rendering issue #151

Closed Guzzy711 closed 7 years ago

Guzzy711 commented 7 years ago

2017-09-30 23_06_32- 2017-09-30 23_07_29-settings - test 2017-09-30 23_08_06-settings - test

As you can see, i got rendering issues? What did i do wrong? :)

kjac commented 7 years ago

Hi @GuzzyMedia,

Looks like you're trying to render a block of Razor within a WebForms template? That won't work :)

Form Editor has no official support for WebForms. If you want to use it in a WebForms context, you'll have to create your own rendering from scratch.

Alternatively you might be able to move the Razor to a macro. Not sure if it'll work, nor how it'll perform (you'll efficiently be mixing two different rendering engines in one page rendering).

-Kenn

Guzzy711 commented 7 years ago

Hello Thanks for the fast response! The thing is, that i'm trying to implement your form into a content page, but i'm not sure where to put the razor.. The template, our content page is using is a webform, and I find it as the only place I can put it into... Do you have the time to help me out?

Guzzy711 commented 7 years ago

2017-10-01 18_39_55- 2017-10-01 18_40_22-developer - 2017-10-01 18_40_33-

I've just tried doing it with a macro.. Can't see what i'm doing wrong.. :(

kjac commented 7 years ago

The log files should probably give you some clues as to what's wrong with your code. My guess is you need to close the code block before calling @Html.Partial(...).

I just tried creating a WebForms master page that calls a Razor macro with the Form Editor rendering. Looks like it works just fine.

Keep in mind though that you're still mixing WebForms and Razor in the same rendering, which might have a performance impact. Also there might just be Form Editor specific things that simply won't work with this solution, as it's never been tested like this.

Here's the master page:

<%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>

<asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">

<!DOCTYPE html>
<html>
<head>
  <title>Test WebForms</title>
  <link rel="stylesheet" href="http://getbootstrap.com/dist/css/bootstrap.min.css"/>
  <style>
    /* required field indicator on the field labels */
    div.form-group.required > label:after {
      content: ' *';
      color: #a94442;
    }
  </style>
</head>
<body>

<umbraco:macro alias="FormEditorMacro" runat="server" />

</body>
</html>

</asp:Content>

...and here's the macro (I've used the NoScript rendering for simplicity, but it can be whatever):

@inherits Umbraco.Web.Macros.PartialViewMacroPage

@* render the form with the NoScript partial *@
@Html.Partial("FormEditor/NoScript", Umbraco.AssignedContentItem)
Guzzy711 commented 7 years ago

You're amazing! You just saved my day.. It was my macro that had some difficulties.. As you can see, i'm still pretty new to Umbraco, so i learned alot from this! 👍
Thanks alot!

kjac commented 7 years ago

You're welcome. Glad you got it working.