Wordpress Gravity Forms Chained选择字段到php

时间:2017-12-17 15:09:48

标签: php wordpress forms pdf gravity-forms-plugin

我正在尝试将Wordpress Gravity Forms数据中的“链式选择”字段引用为PDF。 (我正在关注gravityPDF的开发人员教程。)在示例csv Gravity Forms提供他们的'Chained Selects'附加组件时,它有汽车'Year''Make'和'Model',每个3个表单输入框依赖于事先选择。这恰好是我表格上的第4号字段。 Gravity宏以下列方式将这些引用为合并标记

 {cars (Year):4.1} {cars (Make):4.2} {cars (Model):4.3} 

通常对于像地址这样的东西,很容易找到php所需的典型引用,例如这里列出了几个:https://gravitypdf.com/documentation/v4/developer-php-form-data-array/

在那里,他们显示了从地址6上的合并标签引用引用的地址的子字段:

{Business Address (Street Address):6.1}
{Business Address (Address Line 2):6.2}
{Business Address (City):6.3}
{Business Address (State / Province):6.4}
{Business Address (ZIP / Postal Code):6.5}
{Business Address (Country):6.6}

对此:

/* 6 is the ID of our field */
echo $form_data['field'][6]['street'];
echo $form_data['field'][6]['street2'];
echo $form_data['field'][6]['city'];
echo $form_data['field'][6]['state'];
echo $form_data['field'][6]['zip'];
echo $form_data['field'][6]['country'];

一切正常但我不明白在哪里定义“street2”标签的等价物,例如在汽车数据的数组中。如果我试图复制上述理论,我就这样做:

  {cars (Year):4.1} {cars (Make):4.2} {cars (Model):4.3} 

到此:

<?php 
$f    = $form_data['field'];
$cars = $f[4];
$year = $f[4]['Year'];
$make = $f[4]['Make'];
$model = $f[4]['Model'];
?>

<?php echo $year; ?><br>
<?php echo $make; ?><br>
<?php echo $model; ?><br>

在上面我有效地猜测了这个字段的[street2]等价物,即我放了['Year'] ['Make'] ['Model']并得到“警告:非法字符串偏移'年' “因此在pdf中。

我如何和/或在哪里定义这些标签?如果按照此处建议的那样查看从合并标记生成的pdf中的?data = 1方法:https://gravitypdf.com/documentation/v4/developer-php-form-data-array/那么我只能看到以下字段:

[4.cars] => Array
        [4] => Array
        [cars] => Array

我知道这是一个初学者问题,但我很难找到答案。感谢

0 个答案:

没有答案