Part of the EllisLab Network

Bug Report

form_helper set_value() bug

Date: 06/16/2009 Severity: Trivial
Status: New Reporter: pnd_ku
Version: 1.7.1
Keywords: Helpers, Form Helper

Description

Meet problems when some form fields were not re-populated.

After some debigging found reason - strange behavior.

If form validator initialized set_value() function tries to get value for field from validator. And if field was not set in validator rules - validator returns empty string.

Code Sample

case #1 (bad) - location_address2 is not re-populater

$this->form_validation->set_rules('location_address1', 'Address', 'required');
set_value('location_address1');
set_value('location_address2');

case
#2 (good) - empty rule helps validator to return proper field

$this->form_validation->set_rules('location_address1', 'Address', 'required');
$this->form_validation->set_rules('location_address2', 'Address line 2', '');
set_value('location_address1');
set_value('location_address2');

Expected Result

Expected behavior for set_value()

If validator is used and there are no rules for some field - set_value() should get value from POST and not from validator

Actual Result

Comment on Bug Report

Page 1 of 1 pages
Posted by: Andy Ingham on 2 December 2009 8:48am
no avatar

Hi,

I think that severity for this is more than ‘trivial’. It does waste time finding the bug in the first place and then having to set dummy validation for every form field just so that you can use set_value() function.

Andy

Posted by: jbreitweiser on 4 January 2010 10:13am
no avatar

The code for set_value calls the form_validation object if it exists.  That object only contains data used in form validation.  I put a fix for it in the forums.

http://codeigniter.com/forums/viewthread/96617/P15/

Name:

Email:

Location:

URL:

Remember my personal information

Notify me of follow-up comments?