From c575c8d981f88db6d738c516a06080485e039aed Mon Sep 17 00:00:00 2001 From: marcokernler Date: Mon, 19 Dec 2011 16:47:22 +0100 Subject: [PATCH 1/4] MINOR - Allow pre filled form fields via url params --- code/UserDefinedForm.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/UserDefinedForm.php b/code/UserDefinedForm.php index 06f26e5..16738c2 100755 --- a/code/UserDefinedForm.php +++ b/code/UserDefinedForm.php @@ -405,6 +405,11 @@ class UserDefinedForm_Controller extends Page_Controller { } } + // set the values passed by the url to the field + $request = $this->getRequest(); + $value = $request->getVar( $field->name ); + if( isset( $value ) ) $field->value = $value; + $fields->push($field); } } From 81afd90761c49868d40e7ec4fbdfd970e5ceaffc Mon Sep 17 00:00:00 2001 From: marcokernler Date: Tue, 20 Dec 2011 22:07:40 +0100 Subject: [PATCH 2/4] MINOR - Added documentation to the readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 135d495..ec6b37e 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ and without getting involved in any PHP code. * View submitted submissions and export them to CSV * Define custom error messages and validation settings * Optionally display and hide fields using javascript based on users input +* Pre fill your form fields, by passing your values by url (http://yoursite.com/formpage?EditableField1=MyValue) ## Installation From e24e9b4245c285dbd91d9287b915d5b03188330d Mon Sep 17 00:00:00 2001 From: marcokernler Date: Tue, 20 Dec 2011 22:15:49 +0100 Subject: [PATCH 3/4] MINOR - Now follows the coding conventions --- code/UserDefinedForm.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/UserDefinedForm.php b/code/UserDefinedForm.php index 16738c2..690b90f 100755 --- a/code/UserDefinedForm.php +++ b/code/UserDefinedForm.php @@ -407,8 +407,8 @@ class UserDefinedForm_Controller extends Page_Controller { // set the values passed by the url to the field $request = $this->getRequest(); - $value = $request->getVar( $field->name ); - if( isset( $value ) ) $field->value = $value; + $value = $request->getVar($field->name); + if(isset($value)) $field->value = $value; $fields->push($field); } From ab7e53fb6f0c7f5b08bc1d1cbf745311971b185c Mon Sep 17 00:00:00 2001 From: marcokernler Date: Tue, 20 Dec 2011 22:17:23 +0100 Subject: [PATCH 4/4] MINOR - Added escaping for values passed by url params --- code/UserDefinedForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/UserDefinedForm.php b/code/UserDefinedForm.php index 690b90f..11bfa73 100755 --- a/code/UserDefinedForm.php +++ b/code/UserDefinedForm.php @@ -407,7 +407,7 @@ class UserDefinedForm_Controller extends Page_Controller { // set the values passed by the url to the field $request = $this->getRequest(); - $value = $request->getVar($field->name); + $value = Convert::raw2att($request->getVar($field->name)); if(isset($value)) $field->value = $value; $fields->push($field);