Welcome Guest, Not a member yet? Register   Sign In
What is this helper do?
#1

[eluser]solid9[/eluser]
Hi guys

I just got the codes from this link below,
http://codeigniter.com/wiki/Add_Edit_Views

The helper codes,
Code:
function field($validation, $database = NULL, $last = ''){
$value = (isset($validation)) ? $validation : ( (isset($database)) ? $database : $last);
return $value;
}

Let me try to guess.
If $validation is set then do nothing
else if $database is not set do $last.

What is the use of $database if it is already auto-loaded?
And what the hell is $last do?

So in you opinion what does the codes do?

Thanks in advanced.
#2

[eluser]mrahsanahmad[/eluser]
this is a check if post is working
#3

[eluser]mrahsanahmad[/eluser]
Every thing works fine. However if I change now() (function of date helper) in the last line to :

Code:
anchor(some address,some string);

which is a function of html helper, I get error Call to undefined function anchor()
Code:
$this->CI->html->anchor(some address,some string)
, I get error Call to a member function anchor() on a non-object
Code:
$this->CI->date->now
, I get error Call to a member function now() on a non-object

I have been trying to solve this for hours now. First, I dont understand why should now() function work without the following prefix
Code:
$this->CI->date

to use any library function, I always use the following and this always works
Code:
$this->CI->load->library(myLibrary);
$this->CI->myLibrary->myFunction();

Qs1. Why does helper function such as now() (from date helper) does not require a prefix
Qs2. Assuming that helper functions do not require a prefix, why does this fails in the case of html...

Please guide me so I can move on Smile
#4

[eluser]solid9[/eluser]
@mrahsanahmad
These codes are like black hole.
If some one will try to play with it, they will be trap LOL ha ha ha

I don't understand why they put codes like this in the WIKI if it don't work at all.

I guess the codes are very old, it doesn't work any more in the latest version of CI.

#5

[eluser]InsiteFX[/eluser]
NOTE: This is using the old CI Validation Library and all $validation will need to be changed to $form_validation etc!

anchor is not an html helper it is in the url helper!

Helpers are global to CI
#6

[eluser]solid9[/eluser]
Okay I updated everything to match the latest version of CI.

But when I try to run the script it echo the field helper
why it echo the field helper?
Code:
function field($form_validation, $database = NULL, $last = ''){ $value = (isset($form_validation)) ? $form_validation : ((isset($database)) ? $database : $last); return $value; }

Thanks in advanced.
#7

[eluser]solid9[/eluser]
Okay it's running now.

Just fixed the helper
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
function field($form_validation, $database = NULL, $last = ''){
$value = (isset($form_validation) ? $form_validation : ((isset($database)) ? $database : $last);
return $value;
}

/* End of file field_helper.php */
/* Location: ./system/helpers/field_helper.php */
#8

[eluser]InsiteFX[/eluser]
It's basically do the same as this in the Form_validation library.
Code:
<?php echo validation_errors(); ?>




Theme © iAndrew 2016 - Forum software by © MyBB