HElement StandardForm(Expression <Action> action, ChainFunc <HAttributes.form> extraAttributes, IEnumerable <HInput> inputs) { return (H.form(a => a.method("post") .action(H.Url(action)) .Merge(extraAttributes), H.table( from input in inputs select H.tr ( H.td(input is HiddenInput ? null : H.label(a => a.@for(input.Id), input.Label)), H.td(input.ToElement()) ) ), H.p(H.input(a => a.type("submit").value("OK"))) )); }
HElement StandardForm(Expression<Action> action, ChainFunc<HAttributes.form> extraAttributes, IEnumerable<HInput> inputs) { return H.form(a => a.method("post") .action(H.Url(action)) .Merge (extraAttributes), H.table( from input in inputs select H.tr ( H.td(input is HiddenInput ? null : H.label(a => a.@for(input.Id), input.Label)), H.td(input.ToElement()) ) ), H.p (H.input(a => a.type("submit").value("OK"))) ); }
// this can be improved in the future to intelligently merge other types of attributes. // css is however the most common case. /// <summary> /// Merges two attribute chains with css-awareness. Unlike Join, which merely concatenate two chains, /// Merge merges multiple css attributes into a single css attribute. /// </summary> public static IChain <T> Merge <T> (this IChain <T> x, ChainFunc <T> func) where T : HAttribute, new() { return(x.Join(func).MergeCssAttributes()); }
public static IChain <T> Join <T> (this IChain <T> x, ChainFunc <T> func) { return(x.Join(func == null ? null : func(null))); }
public TextInput(Expression <Func <object> > idExpression, object label = null, ChainFunc <HAttributes.input> attributes = null) : base(idExpression, label, attributes) { }
public HiddenInput(Expression <Func <object> > idExpression, ChainFunc <HAttributes.input> attributes = null) : base(idExpression, null, attributes) { }
public DropDownInput(Expression <Func <object> > idExpression, object label = null, ChainFunc <HAttributes.select> attributes = null, IEnumerable <KeyValuePair <object, string> > options = null) : base(idExpression, label, attributes) { this.options = options; }