我怎样才能插入使用Orchard.Forms保存按钮? [英] How can I insert the Save Button using Orchard.Forms?

查看:186
本文介绍了我怎样才能插入使用Orchard.Forms保存按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

后续的我最初的问题

如果我在代码中创建一个表单正是如此:

If I create a form in code thusly:

public void Describe(DescribeContext context) {
    Func<IShapeFactory, object> form =
        shape => {

            var f = Shape.Form(
                Id: "MyLayoutBasicInformation",
                _BasicInformation: Shape.Fieldset(
                    Title: T("Basic Information"),

                    _FirstName: Shape.TextBox(
                        Id: "FirstName", Name: "First Name",
                        Title: T("First Name"),
                        Description: T("The name for this field")
                        )
                    )
                );
            return f;
        };
    context.Form("MyLayoutBasicInformation", form);
}

和它注入到前端视图正是如此(如答案提供)

And inject it into the front-end view thusly (as the answer provided):

var shape = _formManager.Build("MyLayoutBasicInformation");



我的显示屏只是显示领域的第一品牌。但没有按钮将其保存到数据库中。关于如何实现这一目标的任何想法。

My display just shows the field First Name. But there is no button to save it to the DB. Any thoughts on how to accomplish that?

更新:我用我自己的自定义模块的工作。我有一个应用于它的自定义主题。 。ShapeTracing是给我在交替主题的地方 - 我不知道我想要做的。

UPDATE: I am working with my own custom module. I do have a custom theme applied to it. ShapeTracing is giving me alternates to place in the theme - which I don't know that I want to do.

我把生成的代码在我的控制器正是如此:

I put the Build code in my controller thusly:

[Themed]
    public ActionResult BasicInformation()
    {
        var basicInformation = _formManager.Build("MyLayoutBasicInformation");
        return new ShapeResult(this, basicInformation);
    }



最初,我硬编码与HTML辅助字段。所以,如果我的控制器是myController的,我有这样一个观点:〜/查看/我的/ BasicInformation.cshtml。该文件仍然存在在模块中,但现在被生成的代码重写。

Initially, I hard-coded fields with the HTML helpers. So if my controller was MyController, I had a view like this: ~/Views/My/BasicInformation.cshtml. That file still exists in the module but is now overriden by the Build code.

我怀疑我有玩弄周围。

更新:我设法做到这一点的函数来获得一个按钮的表现,就必须弄清楚如何连接起来。

UPDATE: I managed to to do this in the function to get a button showing, just have to figure out how to wire it up.

_NextButton: Shape.Button(
Id: "NextButton", Name: "Next",
Title: T("Next")
    )

但是,这只是显示没有文本的按钮。

But this just displays a button with no text.

推荐答案

在默认情况下提交按钮将不会为任何形式的建造这种方式产生。添加提交按钮表单更改代码如下:

By default submit button will not generated for any form built this way. to add submit button to your form change your code as following :

public void Describe(DescribeContext context) {
    Func<IShapeFactory, object> form =
        shape => {

            var f = Shape.Form(
                Id: "MyLayoutBasicInformation",
                _BasicInformation: Shape.Fieldset(
                    Title: T("Basic Information"),

                    _FirstName: Shape.TextBox(
                        Id: "FirstName", Name: "First Name",
                        Title: T("First Name"),
                        Description: T("The name for this field")
                        )
                    ),
                    _Submit:Shape.Submit(Value:"Save") 
                );
            return f;
        };
    context.Form("MyLayoutBasicInformation", form);
}

这篇关于我怎样才能插入使用Orchard.Forms保存按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆