Skip to content

Commit

Permalink
Added eval option to upsert values, for doing things like json_encode…
Browse files Browse the repository at this point in the history
…() of dropdown element values, etc.
  • Loading branch information
cheesegrits committed May 14, 2016
1 parent 50b2be1 commit 9eb4e40
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
12 changes: 9 additions & 3 deletions plugins/fabrik_form/upsert/forms/fields.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,26 @@
connection="params_connection_id"
table="params_table"
valueformat="tableelement"
repeat="true"
label="PLG_FORM_UPSERT_KEY_LABEL" />

<field name="upsert_value"
type="text"
size="40"
repeat="true"
label="PLG_FORM_UPSERT_VALUE_LABEL"/>

<field name="upsert_default"
type="text"
repeat="true"
label="PLG_FORM_UPSERT_DEFAULT_LABEL" />

<field name="upsert_eval_value"
default="0"
description="PLG_FORM_UPSERT_VALUE_EVAL_DESC"
label="PLG_FORM_UPSERT_VALUE_EVAL_LABEL"
type="list">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>

</fieldset>
</fields>
</field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ PLG_FORM_UPSERT_ROWID_LABEL="Row value"
PLG_FORM_UPSERT_TABLE_DESC="The Fabrik list to update/insert a record into"
PLG_FORM_UPSERT_TABLE_LABEL="List"
PLG_FORM_UPSERT_VALUE_LABEL="Value"
PLG_FORM_UPSERT_VALUE_EVAL_DESC="Eval the value as PHP"
PLG_FORM_UPSERT_VALUE_EVAL_LABEL="Eval"
7 changes: 7 additions & 0 deletions plugins/fabrik_form/upsert/upsert.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ protected function upsertData($upsertRowExists = false)
$v = $upsert->upsert_value[$i];
$v = $w->parseMessageForPlaceholder($v, $this->data);

if ($upsert->upsert_eval_value[$i] === '1')
{
$res = FabrikHelperHTML::isDebug() ? eval($v) : @eval($v);
FabrikWorker::logEval($res, 'Eval exception : upsert : ' . $v . ' : %s');
$v = $res;
}

if ($v == '')
{
$v = $w->parseMessageForPlaceholder($upsert->upsert_default[$i], $this->data);
Expand Down

0 comments on commit 9eb4e40

Please sign in to comment.