Skip to content

Commit e204e60

Browse files
author
Bitwasp
committed
Fixed validation error on the review form
1 parent ae6e09a commit e204e60

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

application/controllers/reviews.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function form($auth_token = NULL, $order_id = NULL) {
111111
$this->form_validation->set_rules('vendor_shipping', 'the orders shipping', 'callback_check_numeric_rating');
112112
$this->form_validation->set_rules('vendor_comments_source', 'Comments Source', 'callback_check_comments_source');
113113
if($this->input->post('vendor_comments_source') == 'prepared')
114-
$this->form_validation->set_rules('vendor_prepared_comments', 'Vendor Comments', 'callback_check_vendor_prepared_comments');
114+
$this->form_validation->set_rules('vendor_prepared_comments', 'Vendor Comments', 'callback_check_vendor_prepared_comments');
115115
// If user wishes to type in their own data?
116116
if($this->input->post('vendor_comments_source') == 'input')
117117
$this->form_validation->set_rules('vendor_free_comments', 'Vendor Comments', 'max_length[150]|htmlentities');
@@ -145,6 +145,8 @@ public function form($auth_token = NULL, $order_id = NULL) {
145145
}
146146
}
147147

148+
$full_item_post = $this->input->post("item");
149+
148150
// If the review is the long format:
149151
if($this->input->post('review_length') == 'long') {
150152
$c = 0;
@@ -154,13 +156,14 @@ public function form($auth_token = NULL, $order_id = NULL) {
154156
$this->form_validation->set_rules("item[{$c}][quality]", "item ".($c+1)."'s quality", 'callback_check_numeric_rating');
155157
$this->form_validation->set_rules("item[{$c}][matches_desc]", "item ".($c+1)."'s matches description", 'callback_check_numeric_rating');
156158
$this->form_validation->set_rules("item[{$c}][comments_source]", "item ".($c+1)."'s comments source", "callback_check_comments_source");
157-
$item_post = $this->input->post("item[{$c}]");
159+
160+
$item_post = $full_item_post[$c];
158161
// Comments source will determine what rule to apply
159162
if(isset($item_post['comments_source'])) {
160-
if($item_post['comments_source'] == 'prepared')
161-
$this->form_validation->set_rules("item[{$c}][prepared_comments]", "item ".($c+1)."'s comments", "callback_check_prepared_comments");
162-
if($item_post['comments_source'] == 'input')
163+
if($item_post['comments_source'] == 'input')
163164
$this->form_validation->set_rules("item[{$c}][free_comments]", "item ".($c+1)."'s comments","max_length[150]|htmlentities");
165+
if($item_post['comments_source'] == 'prepared')
166+
$this->form_validation->set_rules("item[{$c}][prepared_comments]", "item ".($c+1)."'s comments", "callback_check_item_prepared_comments");
164167
}
165168

166169
if($this->form_validation->run() == TRUE) {
@@ -173,7 +176,7 @@ public function form($auth_token = NULL, $order_id = NULL) {
173176
}
174177
}
175178
}
176-
179+
177180
// If the generated rules are adhered to, we can proceed to store the reviews.
178181
if($this->form_validation->run() == TRUE) {
179182
if($this->review_model->publish_reviews($all_reviews, 'buyer') == TRUE) {

application/views/accounts/view.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<?php if($reviews !== FALSE) { ?>
4343
<div class='row-fluid'>
4444
<div class='well'><strong>Recent Reviews</strong><br />
45-
<?php echo anchor('reviews/view/user/'.$user['user_hash'], "[All Reviews ({$review_count['all']})]"); ?> <?php echo anchor('reviews/view/user/'.$user['user_hash'].'/0', "[Positive Reviews ({$review_count['positive']})]"); ?> <?php echo anchor('reviews/view/user/'.$user['user_hash'].'/1', "[Disputed Reviews {$review_count['disputed']}]"); ?>
45+
<?php echo anchor('reviews/view/user/'.$user['user_hash'], "[All Reviews ({$review_count['all']})]"); ?> <?php echo anchor('reviews/view/user/'.$user['user_hash'].'/0', "[Positive Reviews ({$review_count['positive']})]"); ?> <?php echo anchor('reviews/view/user/'.$user['user_hash'].'/1', "[Disputed Orders {$review_count['disputed']}]"); ?>
4646
<?php foreach($reviews as $review) { ?>
4747
<br /><div class='row-fluid'>
4848
<div class='span3'><?php foreach($review['rating'] as $rating_name => $rating){ echo ucfirst($rating_name) ." - $rating/5<br />"; } ?>Average: <?php echo $review['average_rating']; ?></div>

application/views/reviews/form.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
<br />
3838

3939
<?php echo form_open($action_page, array('class' => 'form-horizontal')); ?>
40-
<?php echo form_error('review_length'); ?>
40+
41+
<?php echo validation_errors().form_error('review_length'); ?>
4142
<div class='row-fluid'>
4243
<div class='well' style='background-color:white;'>
4344
<h4>Vendor Feedback</h4>
@@ -174,7 +175,7 @@
174175
<div class='span7'>
175176
<?php echo form_error("item[{$c}][comments_source]"); ?>
176177
<input type='radio' name='item[<?php echo $c; ?>][comments_source]' value='prepared' /> Use prepared statements? <br />
177-
<select name='item[<?php echo $c; ?>][comments_prepared]' autocomplete='off'>
178+
<select name='item[<?php echo $c; ?>][prepared_comments]' autocomplete='off'>
178179
<option value=''></option>
179180
<option value='Did not match description.'>Did not match description.</option>
180181
<option value='Poor quality.'>Poor quality.</option>

version.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bitwasp_created_time=1393927781
1+
bitwasp_created_time=1393929543

0 commit comments

Comments
 (0)