Enhancements/Corrections in form_helper and form_validation

#1
[eluser]j2more[/eluser]
Hi there.

I am using CI 1.7.1:

I suggest to enhance/correct the following in form_helper/form_validator:

Currently these classes are not designed to prepopulate fields in forms, but just submitted forms that return some errors typically. With only some small changes this can be achieved though.
Goals:
- I would like to prepopulate my unsubmitted form with values
- I do not want to load form validator for this
- I would like this to be working with several forms in a page

Solution:
change the following files as below:

It works for me. Discussion welcome, Ben

set_select:
form_validation line 748:
old: if ($default === TRUE AND count($this->_field_data) === 0)
new: if ($default === TRUE )

form helper: line 647:
old: if (count($_POST) === 0 )
new: if (count($_POST) === 0 && $default)

set_radio:
form_helper line 755:
old:if (count($_POST) === 0 )
new: if (count($_POST) === 0 && $default )

form_Validation: line 792;
old:if ($default === TRUE AND count($this->_field_data) === 0)
new:if ($default === TRUE )

set_checkbox:
form_helper line 702:
old:if (count($_POST) === 0 )
new:if (count($_POST) === 0 && $default)

form_validation line: 832:
old:if ($default === TRUE AND count($this->_field_data) === 0)
new:if ($default === TRUE )

set_value is already correct..


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.