Fixes issue with UmbracoHelper in back office when there is not Document.
Adds another overload to BeginUmbracoForm.
This commit is contained in:
@@ -306,6 +306,19 @@ namespace Umbraco.Web
|
||||
return html.BeginUmbracoForm(action, typeof(T), additionalRouteVals, htmlAttributes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to create a new form to execute in the Umbraco request pipeline to a surface controller plugin
|
||||
/// </summary>
|
||||
/// <param name="html"></param>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="controllerName"></param>
|
||||
/// <param name="area"></param>
|
||||
/// <returns></returns>
|
||||
public static MvcForm BeginUmbracoForm(this HtmlHelper html, string action, string controllerName, string area)
|
||||
{
|
||||
return html.BeginUmbracoForm(action, controllerName, area, null, new Dictionary<string, object>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to create a new form to execute in the Umbraco request pipeline to a surface controller plugin
|
||||
/// </summary>
|
||||
|
||||
@@ -311,6 +311,7 @@
|
||||
<Compile Include="umbraco.presentation\umbraco\nodeFactory\UmbracoSiteMapProviderAccessUpdate.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\settings\views\editView.aspx.cs">
|
||||
<DependentUpon>editView.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\uQuery\IGetProperty.cs" />
|
||||
<Compile Include="UmbracoHelper.cs" />
|
||||
|
||||
@@ -245,7 +245,7 @@ namespace Umbraco.Web
|
||||
/// <summary>
|
||||
/// Gets the current page ID, or <c>null</c> if no page ID is available (e.g. a custom page).
|
||||
/// </summary>
|
||||
public virtual int? PageId
|
||||
public int? PageId
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -265,7 +265,7 @@ namespace Umbraco.Web
|
||||
/// Gets the current logged in Umbraco user (editor).
|
||||
/// </summary>
|
||||
/// <value>The Umbraco user object or null</value>
|
||||
public virtual User UmbracoUser
|
||||
public User UmbracoUser
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -277,7 +277,7 @@ namespace Umbraco.Web
|
||||
/// <summary>
|
||||
/// Determines whether the current user is in a preview mode and browsing the site (ie. not in the admin UI)
|
||||
/// </summary>
|
||||
public virtual bool InPreviewMode
|
||||
public bool InPreviewMode
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
@@ -37,8 +37,12 @@ namespace Umbraco.Web
|
||||
internal UmbracoHelper(UmbracoContext umbracoContext)
|
||||
{
|
||||
if (umbracoContext == null) throw new ArgumentNullException("umbracoContext");
|
||||
if (umbracoContext.RoutingContext == null) throw new NullReferenceException("The RoutingContext on the UmbracoContext cannot be null");
|
||||
_umbracoContext = umbracoContext;
|
||||
_currentPage = _umbracoContext.DocumentRequest.Document;
|
||||
if (_umbracoContext.IsFrontEndUmbracoRequest)
|
||||
{
|
||||
_currentPage = _umbracoContext.DocumentRequest.Document;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,6 +134,10 @@ namespace Umbraco.Web
|
||||
RenderFieldEncodingType encoding = RenderFieldEncodingType.Unchanged,
|
||||
string formatString = "")
|
||||
{
|
||||
if (_currentPage == null)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot call this method when not rendering a front-end document");
|
||||
}
|
||||
return Field(_currentPage, fieldAlias, valueAlias, altFieldAlias, altValueAlias,
|
||||
altText, insertBefore, insertAfter, recursive, convertLineBreaks, removeParagraphTags,
|
||||
casing, encoding, formatString);
|
||||
|
||||
Reference in New Issue
Block a user