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

Date picker stylesheet not rendered #73

Closed
tomvanenckevort opened this issue Jan 25, 2019 · 1 comment
Closed

Date picker stylesheet not rendered #73

tomvanenckevort opened this issue Jan 25, 2019 · 1 comment

Comments

@tomvanenckevort
Copy link

After upgrading a site to Umbraco Forms v7.0.6 I encountered an issue with the date picker stylesheet (for Pikaday) missing from the page.

This happens when you not render the scripts with the form, but elsewhere on the page (as described here).

Reproduction

Create a form and make sure it includes a date picker field.

Insert a form in a view using the macro script, making sure to exclude the scripts:

@Umbraco.RenderMacro("renderUmbracoForm", new { FormGuid = Model.Form, FormTheme = "default", RecordId = Guid.Empty, ExcludeScripts = "1" })

(in this case Model.Form contains the GUID of the form, but you can also hardcode it for testing purposes).

Next up, render the form scripts further down the page:

@if (TempData["UmbracoForms"] != null)
{
    foreach (var form in (List<Guid>)TempData["UmbracoForms"])
    {
        Html.RenderAction("RenderFormScripts", "UmbracoForms", new { formid = form, theme = "default" });
    }
}

View the page and when highlighting the date picker you will notice all the styling is missing.

Bug summary

The issue is that the pikaday CSS is no longer included on the page. I noticed that the way it's added has changed in this latest version, using:

Html.AddFormThemeCssFile("~/App_Plugins/UmbracoForms/Assets/pikaday/pikaday.css");

(line 12 in Views\Partials\Forms\Datepicker.cshtml)

But then it's not rendered out anywhere.

Workaround/fix

I managed to fix it by modifying Views\Partials\Forms\Themes\default\Script.cshtml:

@* Render references to javascript files needed by fields on the current page*@
if (Model.UseClientDependency)
{
    foreach (var css in Html.GetThemeCssFiles(Model))
    {
        Html.RequiresCss(css.Value);
    }

    foreach (var script in Html.GetThemeScriptFiles(Model))
    {
        Html.RequiresJs(script.Value, Model.JavaScriptTagAttributes);
    }
}
else
{
    @Html.RenderFormsStylesheets(Url, Model)

    @Html.RenderFormsScripts(Url, Model, Model.JavaScriptTagAttributes)
}

(this is from line 41 in that file)

This fixes the issue and makes sure the Pikaday CSS does get loaded on the page.

@bergmania
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants