pull/279/head
Halil İbrahim Kalkan 8 years ago
commit 2963033713

@ -16,6 +16,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers
where TTagHelper : TagHelper
{
protected const string FormGroupContents = "FormGroupContents";
protected const string AbpFormContentPlaceHolder = "{_AbpFormContentPlaceHolder_}";
public TTagHelper TagHelper { get; internal set; }

@ -37,13 +37,13 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
NormalizeTagMode(context, output);
await output.GetChildContentAsync();
var childContent = (await output.GetChildContentAsync()).GetContent();
await ConvertToMvcForm(context, output);
ProcessFields(context, output);
SetContent(output, list);
SetContent(context, output, list, childContent);
SetFormAttributes(context, output);
@ -86,16 +86,25 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
output.Attributes.AddIfNotContains("method", "post");
}
protected virtual void SetContent(TagHelperOutput output, List<FormGroupItem> items)
protected virtual void SetContent(TagHelperContext context, TagHelperOutput output, List<FormGroupItem> items, string childContent)
{
var preContentBuilder = new StringBuilder(output.PreContent.GetContent());
var contentBuilder = new StringBuilder("");
foreach (var item in items.OrderBy(o => o.Order))
{
preContentBuilder.AppendLine(item.HtmlContent);
contentBuilder.AppendLine(item.HtmlContent);
}
output.PreContent.SetHtmlContent(preContentBuilder.ToString());
if (childContent.Contains(AbpFormContentPlaceHolder))
{
childContent = childContent.Replace(AbpFormContentPlaceHolder, contentBuilder.ToString());
}
else
{
childContent = contentBuilder + childContent;
}
output.Content.SetHtmlContent(childContent);
}
protected virtual void SetSubmitButton(TagHelperContext context, TagHelperOutput output)
@ -221,24 +230,12 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
return type.IsPrimitive ||
type.IsValueType ||
type == typeof(string) ||
type == typeof(Guid) ||
type == typeof(DateTime) ||
type == typeof(ValueType) ||
type == typeof(String) ||
type == typeof(Decimal) ||
type == typeof(Double) ||
type == typeof(Guid) ||
type == typeof(Char) ||
type == typeof(Byte) ||
type == typeof(Boolean) ||
type == typeof(TimeSpan) ||
type == typeof(DateTimeOffset) ||
type == typeof(Int16) ||
type == typeof(Int32) ||
type == typeof(Int64) ||
type == typeof(ushort) ||
type == typeof(uint) ||
type == typeof(ulong) ||
type == typeof(float) ||
type.IsEnum;
}

@ -0,0 +1,15 @@
using Microsoft.AspNetCore.Razor.TagHelpers;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
{
[HtmlTargetElement("abp-form-content", TagStructure = TagStructure.WithoutEndTag)]
public class AbpFormContentTagHelper : AbpTagHelper<AbpFormContentTagHelper, AbpFormContentTagHelperService>, ITransientDependency
{
public AbpFormContentTagHelper(AbpFormContentTagHelperService tagHelperService)
: base(tagHelperService)
{
}
}
}

@ -0,0 +1,16 @@
using Microsoft.AspNetCore.Razor.TagHelpers;
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers;
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
{
public class AbpFormContentTagHelperService : AbpTagHelperService<AbpFormContentTagHelper>
{
public override void Process(TagHelperContext context, TagHelperOutput output)
{
output.Attributes.Clear();
output.TagName = "div";
output.TagMode = TagMode.StartTagAndEndTag;
output.Content.SetContent(AbpFormContentPlaceHolder);
}
}
}

File diff suppressed because it is too large Load Diff

@ -27,7 +27,7 @@
</div>
<div class="code-area">
<pre>
&lt;abp-dynamic-form abp-model=&quot;Model.PersonInput&quot; asp-antiforgery=&quot;true&quot;/&gt;
&lt;abp-dynamic-form abp-model=&quot;Model.PersonInput&quot;/&gt;
</pre>
</div>
</div>
@ -38,6 +38,7 @@
<div class="demo-area">
<abp-dynamic-form abp-model="@Model.PersonInput">
<abp-input asp-for="@Model.PersonInput.Phone.Number" label="Phone Number" />
<abp-button button-type="Primary" type="submit" text="submit" />
</abp-dynamic-form>
<hr />
<h5>Posted Values:</h5>
@ -129,4 +130,33 @@
</div>
</div>
<h4># Form Content Placement </h4>
<div class="demo-with-code">
<div class="demo-area">
<abp-dynamic-form abp-model="@Model.PersonInput">
<abp-form-content />
<abp-button button-type="Primary" type="submit" text="submit" />
</abp-dynamic-form>
<hr />
<h5>Posted Values:</h5>
<div>
Name: @Model.PersonInput.Name <br />
City: @Model.PersonInput.City <br />
Phone.Name: @Model.PersonInput.Phone.Name <br />
Phone.Number: @Model.PersonInput.Phone.Number <br />
Day: @Model.PersonInput.Day.ToString("yyyy-MM-dd") <br />
Country: @Model.PersonInput.Country <br />
IsActive: @Model.PersonInput.IsActive <br />
</div>
</div>
<div class="code-area">
<pre>
&lt;abp-dynamic-form abp-model=&quot;@Model.PersonInput&quot;&gt;
&lt;abp-form-content /&gt;
&lt;abp-button button-type=&quot;Primary&quot; type=&quot;submit&quot; text=&quot;submit&quot; /&gt;
&lt;/abp-dynamic-form&gt;
</pre>
</div>
</div>

Loading…
Cancel
Save