在Gravity Forms中设置Name字段的默认值

时间:2018-02-08 05:51:51

标签: php forms gravity

在Gravity Forms中,您可以使用以下代码设置字段的默认值:

ApplicationDbContext

这在文档中提到:https://docs.gravityforms.com/field-object/

然而,这对于Name字段不起作用,因为它是一个多输入字段,因为它包含名字和姓氏。如何在Gravity Forms中设置名称字段的默认值?

1 个答案:

答案 0 :(得分:1)

如前所述,“名称”字段是一个多输入字段。您必须在多输入字段上与所需的输入进行交互。例如,要设置名字,您可以执行以下操作:

$field->inputs[2]['defaultValue'] = 'Dave';

以下是inputs字段属性的完整内容,为JSON:

[{ "id": "9.2", "label": "Prefix", "name": "", "choices": [{ "text": "Mr.", "value": "Mr.", "isSelected": false, "price": "" }, { "text": "Mrs.", "value": "Mrs.", "isSelected": false, "price": "" }, { "text": "Miss", "value": "Miss", "isSelected": false, "price": "" }, { "text": "Ms.", "value": "Ms.", "isSelected": false, "price": "" }, { "text": "Dr.", "value": "Dr.", "isSelected": false, "price": "" }, { "text": "Prof.", "value": "Prof.", "isSelected": false, "price": "" }, { "text": "Rev.", "value": "Rev.", "isSelected": false, "price": "" }], "isHidden": true, "inputType": "radio", "defaultValue": "Mr." }, { "id": "9.3", "label": "First", "name": "", "defaultValue": "David" }, { "id": "9.4", "label": "Middle", "name": "", "isHidden": true, "defaultValue": "Stover" }, { "id": "9.6", "label": "Last", "name": "", "defaultValue": "Smith" }, { "id": "9.8", "label": "Suffix", "name": "", "isHidden": true, "defaultValue": "Jr." }]