Skip to content

Commit

Permalink
FormLocationKey ArgumentNullException (OrchardCMS#14936)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtkech authored and urbanit committed Mar 18, 2024
1 parent 9579f04 commit 4257bc1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,16 @@ public override IEnumerable<Outcome> GetPossibleOutcomes(WorkflowExecutionContex

public string FormLocationKey
{
get => GetProperty<string>();
set => SetProperty(value);
get => GetProperty(() => string.Empty);
set => SetProperty(value ?? string.Empty);
}

public override Task<ActivityExecutionResult> ExecuteAsync(WorkflowExecutionContext workflowContext, ActivityContext activityContext)
{
if (workflowContext.Output.TryGetValue(WorkflowConstants.HttpFormLocationOutputKeyName, out var obj)
&& obj is Dictionary<string, string> formLocations)
{
// if no custom location-key was provided, we use empty string as the default key.
var location = FormLocationKey ?? string.Empty;

if (formLocations.TryGetValue(location, out var path))
if (formLocations.TryGetValue(FormLocationKey, out var path))
{
_httpContextAccessor.HttpContext.Items[WorkflowConstants.FormOriginatedLocationItemsKey] = path;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
<label asp-for="FormLocationKey" class="form-label">@T["Form Location Key"]</label>
<input type="text" asp-for="FormLocationKey" class="form-control" />
<span asp-validation-for="FormLocationKey"></span>
<span class="hint">@T["This value needs to correspond with the Form Location Key value utilized in the HTTP request event settings. Leave blank if the workflow handles a single form event."]</span>
<span class="hint">@T["This key name should be equal to the 'Form Location Key' of the HTTP request event. Leave blank if the workflow only handles a single form."]</span>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public int TokenLifeSpan

public string FormLocationKey
{
get => GetProperty<string>();
set => SetProperty(value);
get => GetProperty(() => string.Empty);
set => SetProperty(value ?? string.Empty);
}

public override bool CanExecute(WorkflowExecutionContext workflowContext, ActivityContext activityContext)
Expand All @@ -77,13 +77,10 @@ public override Task<ActivityExecutionResult> ExecuteAsync(WorkflowExecutionCont
if (!workflowContext.Output.TryGetValue(WorkflowConstants.HttpFormLocationOutputKeyName, out var obj)
|| obj is not Dictionary<string, string> formLocation)
{
formLocation = new Dictionary<string, string>();
formLocation = [];
}

// if no custom location-key was provided, we use empty string as the default key.
var location = FormLocationKey ?? string.Empty;

formLocation[location] = GetLocationUrl(value);
formLocation[FormLocationKey] = GetLocationUrl(value);

workflowContext.Output[WorkflowConstants.HttpFormLocationOutputKeyName] = formLocation;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@


<div class="mb-3" asp-validation-class-for="FormLocationKey">
<label asp-for="FormLocationKey" class="form-label">@T["Form Location"]</label>
<label asp-for="FormLocationKey" class="form-label">@T["Form Location Key"]</label>
<input type="text" asp-for="FormLocationKey" class="form-control" />
<span asp-validation-for="FormLocationKey"></span>
<span class="hint">@T["This key serves to differentiate the current form's location. Leave blank if the workflow handles a single form event."]</span>
<span class="hint">@T["This key name is used to store and then retrieve the current form's location. Leave blank if the workflow doesn't handle any form or a single one."]</span>
</div>

<script depends-on="jQuery" asp-src="~/OrchardCore.Workflows/Scripts/orchard.http-request-event-editor.min.js" debug-src="~/OrchardCore.Workflows/Scripts/orchard.http-request-event-editor.js" at="Foot"></script>
Expand Down

0 comments on commit 4257bc1

Please sign in to comment.