mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Some experimentation with form-like shapes
--HG-- branch : mvc3p1
This commit is contained in:
@@ -54,7 +54,18 @@ namespace Orchard.DevTools.Controllers {
|
|||||||
return View("Simple", new Simple { Title = "This is not themed", Quantity = 5 });
|
return View("Simple", new Simple { Title = "This is not themed", Quantity = 5 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ActionResult FormShapes() {
|
||||||
|
var model = Shape.Form(Submit: Shape.FormSubmit(Text: T("Finish Setup")))
|
||||||
|
.Fieldsets(Shape.Zone(typeof (Array), Name: "Fieldsets"));
|
||||||
|
|
||||||
|
model.Fieldsets.Add(Shape.InputText(Name: "SiteName", Text: T("Site Name"), Value: T("some default/pre-pop value...")));
|
||||||
|
model.Fieldsets.Add(Shape.InputText(Name: "AdminUsername", Text: T("Admin Username")));
|
||||||
|
model.Fieldsets.Add(Shape.InputPassword(Name: "AdminPassword", Text: T("Admin Password")));
|
||||||
|
|
||||||
|
model.Fieldsets[0].Attributes(new {autofocus = "autofocus"}); // <-- could be applied by some other behavior - need to be able to modify attributes instead of clobbering them like this
|
||||||
|
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
public ActionResult UsingShapes() {
|
public ActionResult UsingShapes() {
|
||||||
|
|
||||||
|
@@ -125,6 +125,7 @@
|
|||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="Views\Home\FormShapes.cshtml" />
|
||||||
<None Include="Views\Home\UsingShapes.cshtml" />
|
<None Include="Views\Home\UsingShapes.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
|
@@ -0,0 +1,3 @@
|
|||||||
|
<div>
|
||||||
|
the form -> @Display(Model)
|
||||||
|
</div>
|
@@ -1,6 +1,5 @@
|
|||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using System.Web.Routing;
|
|
||||||
using ClaySharp;
|
using ClaySharp;
|
||||||
using Orchard.DisplayManagement;
|
using Orchard.DisplayManagement;
|
||||||
|
|
||||||
@@ -19,5 +18,28 @@ namespace Orchard.Mvc.Html {
|
|||||||
tagBuilder.MergeAttribute("src", Url);
|
tagBuilder.MergeAttribute("src", Url);
|
||||||
return Display(new HtmlString(tagBuilder.ToString(TagRenderMode.SelfClosing)));
|
return Display(new HtmlString(tagBuilder.ToString(TagRenderMode.SelfClosing)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region form and company
|
||||||
|
|
||||||
|
public IHtmlString Form(dynamic Display, dynamic Shape, object Submit) {
|
||||||
|
return Display(new HtmlString("<form>" + Display(Shape.Fieldsets, Submit).ToString() + "</form>"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IHtmlString FormSubmit(dynamic Display, dynamic Shape) {
|
||||||
|
return Display(new HtmlString("<button type='submit'>" + Shape.Text + "</button>"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IHtmlString InputPassword(dynamic Display, dynamic Shape) {
|
||||||
|
return Display(new HtmlString("<label>" + Shape.Text + "</label><input type='password' name='" + Shape.Name + "' value='" + (Shape.Value == null ? "" : Shape.Value) + "' />"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IHtmlString InputText(dynamic Display, dynamic Shape, INamedEnumerable<object> Attributes) {
|
||||||
|
// not optimal obviously, just testing the waters
|
||||||
|
return Display(new HtmlString("<label>" + Shape.Text + "</label>"
|
||||||
|
+ "<input type='text'" + (Attributes.Named.ContainsKey("autofocus") ? " autofocus" : "" )+ " name='" + Shape.Name
|
||||||
|
+ "' value='" + (Shape.Value == null ? "" : Shape.Value) + "' />")); // <- otherwise Shape.Value is "ClaySharp.Clay"
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user