Skip to content

Commit

Permalink
Update to 1.0.1
Browse files Browse the repository at this point in the history
- Add: param ignoreFields to db2Formit
- Change: paramname/fieldname of db2Formit are compared with the REQUEST array instead of GET array
- Bugfix: wrong parameter names in db2Formit code (now paramname/fieldname as documented)
  • Loading branch information
Jako committed Apr 12, 2013
1 parent 6b0d276 commit a84af74
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ Changelog

- 1.0
- Initial public release as package for MODX Revolution
- 1.0.1
- Add: param ignoreFields to db2Formit
- Change: paramname/fieldname of db2Formit are compared with the REQUEST array instead of GET array
- Bugfix: wrong parameter names in db2Formit code (now paramname/fieldname as documented)
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ prefix | Table prefix of the xPDO package.
packagename | Package name of the xPDO object. | -
classname | Class name of the xPDO object. | -
where | JSON encoded xPDO where clause - to retreive an existing row. | -
paramname | Requested POST param - to retreive an existing row. | -
fieldname | xPDO fieldname the POST param is compared with - to retreive an existing row. | 'paramname'
paramname | Requested REQUEST param - to retreive an existing row. | -
fieldname | xPDO fieldname the REQUEST param is compared with - to retreive an existing row. | 'paramname'
arrayFormat | Format to transform form fields that contains array data (i.e. checkboxes) into | csv
arrayFields | JSON encoded array of form fields that are transformed into arrays | []
arrayFields | JSON encoded array of database fields that are transformed into arrays | []
ignoreFields | JSON encoded array of database fields that are not retreived into FormIt | []
notFoundRedirect | ID of the MODX resource the user is redirected to, if the requested row is not found | 0

Note
Expand Down
2 changes: 1 addition & 1 deletion _build/build.transport.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/* define package */
define('PKG_NAME', 'FormIt2db');
define('PKG_NAME_LOWER', strtolower(PKG_NAME));
define('PKG_VERSION', '1.0');
define('PKG_VERSION', '1.0.1');
define('PKG_RELEASE', 'pl');

/* define sources */
Expand Down
8 changes: 8 additions & 0 deletions _build/properties/properties.db2formit.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@
'value' => '[]',
'lexicon' => 'formit2db:properties',
),
array(
'name' => 'ignoreFields',
'desc' => 'prop_db2formit.ignoreFields',
'type' => 'textfield',
'options' => '',
'value' => '[]',
'lexicon' => 'formit2db:properties',
),
array(
'name' => 'notFoundRedirect',
'desc' => 'prop_db2formit.notFoundRedirect',
Expand Down
4 changes: 4 additions & 0 deletions core/components/formit2db/docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ Changelog

- 1.0
- Initial public release as package for MODX Revolution
- 1.0.1
- Add: param ignoreFields to db2Formit
- Change: paramname/fieldname of db2Formit are compared with the REQUEST array instead of GET array
- Bugfix: wrong parameter names in db2Formit code (now paramname/fieldname as documented)
10 changes: 6 additions & 4 deletions core/components/formit2db/docs/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ packagename | Package name of the xPDO object. | -
classname | Class name of the xPDO object. | -
where | JSON encoded xPDO where clause - to retreive | -
| an existing row. |
paramname | Requested POST param - to retreive an | -
paramname | Requested REQUEST param - to retreive an | -
| existing row. |
fieldname | xPDO fieldname the POST param is compared | 'paramname'
fieldname | xPDO fieldname the REQUEST param is compared | 'paramname'
| with - to retreive an existing row. |
arrayFormat | Format to transform form fields that | csv
| contains array data (i.e. checkboxes) into |
arrayFields | JSON encoded array of form fields that are | []
| transformed into arrays |
arrayFields | JSON encoded array of database fields that | []
| are transformed into arrays |
ignoreFields | JSON encoded array of database fields that | []
| are not retreived into FormIt |
notFoundRedirect | ID of the MODX resource the user is | 0
| redirected to, if the requested row is not |
| found |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
$packagename = $modx->getOption('packagename', $scriptProperties, '', true);
$classname = $modx->getOption('classname', $scriptProperties, '', true);
$where = $modx->fromJson($modx->getOption('where', $scriptProperties, '', true));
$paramname = $modx->getOption('paramName', $scriptProperties, '', true);
$fieldname = $modx->getOption('fieldName', $scriptProperties, $paramname, true);
$paramname = $modx->getOption('paramname', $scriptProperties, '', true);
$fieldname = $modx->getOption('fieldname', $scriptProperties, $paramname, true);
$arrayFormat = $modx->getOption('arrayFormat', $scriptProperties, 'csv', true);
$arrayFields = $modx->fromJson($modx->getOption('arrayFields', $scriptProperties, '[]', true));
$ignoreFields = $modx->fromJson($modx->getOption('ignoreFields', $scriptProperties, '[]', true));
$notFoundRedirect = intval($modx->getOption('notFoundRedirect', $scriptProperties, '0'), true);

$packagepath = $modx->getOption('core_path') . 'components/' . $packagename . '/';
Expand All @@ -41,9 +42,9 @@

if ($fieldname) {
if (is_array($where)) {
$where[$fieldname] = $_GET[$paramname];
$where[$fieldname] = $_REQUEST[$paramname];
} else {
$where = array($fieldname => $_GET[$paramname]);
$where = array($fieldname => $_REQUEST[$paramname]);
}
}

Expand All @@ -59,6 +60,9 @@
}
$formFields = $dataobject->toArray();
foreach ($formFields as $field => $value) {
if (in_array($field, $ignoreFields)) {
unset($formFields[$field]);
}
if (in_array($field, $arrayFields)) {
switch ($arrayFormat) {
case 'json': {
Expand Down
7 changes: 4 additions & 3 deletions core/components/formit2db/lexicon/en/properties.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
$_lang['prop_db2formit.packagename'] = $_lang['prop_formit2db.packagename'];
$_lang['prop_db2formit.classname'] = $_lang['prop_formit2db.classname'];
$_lang['prop_db2formit.where'] = 'JSON encoded xPDO where clause - to retreive an existing row';
$_lang['prop_db2formit.paramname'] = 'Requested GET param - to retreive an existing row';
$_lang['prop_db2formit.fieldname'] = 'xPDO fieldname the GET param is compared with - to retreive an existing row';
$_lang['prop_db2formit.paramname'] = 'Requested REQUEST param - to retreive an existing row';
$_lang['prop_db2formit.fieldname'] = 'xPDO fieldname the REQUEST param is compared with - to retreive an existing row';
$_lang['prop_db2formit.arrayFormat'] = 'Format to transform form fields that contains array data (i.e. checkboxes) from';
$_lang['prop_db2formit.arrayFields'] = 'JSON encoded array of form fields that are transformed into arrays i.e. ["field_1", "field_2"]';
$_lang['prop_db2formit.arrayFields'] = 'JSON encoded array of database fields that are transformed into arrays i.e. ["field_1", "field_2"]';
$_lang['prop_db2formit.ignoreFields'] = 'JSON encoded array of database fields that are not retreived into FormIt i.e. ["field_1", "field_2"]';
$_lang['prop_db2formit.notFoundRedirect'] = 'ID of the MODX resource the user is redirected to, if the requested row is not found';

0 comments on commit a84af74

Please sign in to comment.