Skip to content

Commit

Permalink
Merge pull request #13 from ibrahimlawal/hotfix/uniqfileinputfieldids
Browse files Browse the repository at this point in the history
ensure the IDs of file input form text fields are random. This fixes #10
  • Loading branch information
steveamaza authored Nov 14, 2017
2 parents 348c094 + 1a55c96 commit 0c0b8d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions public/class-paystack-forms-public-for-old-themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,7 @@ function kkd_pff_paystack_input_shortcode($atts) {
'required' => '0',
), $atts));

$uniqq = kkd_pff_paystack_generate_new_code();
$code = '<div class="span12 unit">
<label class="label">'.$name;
if ($required == 'required') {
Expand All @@ -1140,12 +1141,12 @@ function kkd_pff_paystack_input_shortcode($atts) {
<div class="input append-small-btn">
<div class="file-button">
Browse
<input type="file" name="'.$name.'" onchange="document.getElementById(\'append-small-btn\').value = this.value;"';
<input type="file" name="'.$name.'" onchange="document.getElementById(\'append-small-btn-'.$uniqq.'\').value = this.value;"';
if ($required == 'required') {
$code.= ' required="required" ';
}
$code.= '" /></div>
<input type="text" id="append-small-btn" readonly="" placeholder="no file selected">
<input type="text" id="append-small-btn-'.$uniqq.'" readonly="" placeholder="no file selected">
</div></div>';
return $code;
}
Expand Down
5 changes: 3 additions & 2 deletions public/class-paystack-forms-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,7 @@ function kkd_pff_paystack_input_shortcode($atts) {
'required' => '0',
), $atts));

$uniqq = kkd_pff_paystack_generate_new_code();
$code = '<div class="span12 unit">
<label class="label">'.$name;
if ($required == 'required') {
Expand All @@ -1140,12 +1141,12 @@ function kkd_pff_paystack_input_shortcode($atts) {
<div class="input append-small-btn">
<div class="file-button">
Browse
<input type="file" name="'.$name.'" onchange="document.getElementById(\'append-small-btn\').value = this.value;"';
<input type="file" name="'.$name.'" onchange="document.getElementById(\'append-small-btn-'.$uniqq.'\').value = this.value;"';
if ($required == 'required') {
$code.= ' required="required" ';
}
$code.= '" /></div>
<input type="text" id="append-small-btn" readonly="" placeholder="no file selected">
<input type="text" id="append-small-btn-'.$uniqq.'" readonly="" placeholder="no file selected">
</div></div>';
return $code;
}
Expand Down

0 comments on commit 0c0b8d5

Please sign in to comment.