Welcome Guest, Not a member yet? Register   Sign In
Variable naming curiosity
#1

[eluser]satterle[/eluser]
I created an array variable of values to plug into a form_textarea(). The curiosity is this: When I name the variable 'fmeDescription' it ends up as an empty array. When I name it anything else, such as 'stuff' or 'xmeDescription' or 'fmxDescription', it works. Any ideas why?
#2

[eluser]Randy Casburn[/eluser]
Hi satterle -- need some help with your description.

First this part: By "..., it works." I presume you mean the Form Help Class text area method works right?

So when you say "it ends up as an empty array" does that mean your <textarea> tag is not constructed correctly, not at all, it is but not with the attributes you specified, etc. What exactly do you mean?

Is it possible you've used 'fmeDescription' elsewhere in the scope of this variable and the you're overwriting the variable someplace else?
#3

[eluser]satterle[/eluser]
OK - more detail.

In the me_model, I created a function (form_data) and declared an array:

$data['fmeDescription'] = array('name'=>'meDescription', 'rows'=>3, 'cols'=>30);

I load the array in the controller:

$this->load->model('me_model');
$data = $this->me_model->form_data();
$this->load->view('form_view', $data);

In the view, I use the data:

print form_textarea($fmeDescription);

The issue is that when the array is named 'fmeDescription', the values do not populate the textarea tag <... name="" rows="12" cols="90">. There are about 15 arrays declared in the 'form_data' function and are used in the 'form_view' view. All work as expected. When I change the array name to 'stuff' or 'xmeDescription' or 'fxeDescription', the textarea tag is populated properly <... name="stuff" rows="3" cols="30">.

I suspect that I have stumbled upon an undocumented reserved name but can't find anything on it. The only thing on google is my original post :-).
#4

[eluser]Randy Casburn[/eluser]
Don't think it's a reserved word.

The Form Help Class is choking on your array for some reason right here:

Code:
$defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'cols' => '90', 'rows' => '12');

This will sound weird, but do me a favor and put quotes around your integers '3' and '90' for me and let me know what happens.
#5

[eluser]satterle[/eluser]
That worked!

Still doesn't explain why 'fmeDescription' without the quotes didn't work while 'fmxDescription' without the quotes did work. Oh well. Another mystery of the universe?
#6

[eluser]Randy Casburn[/eluser]
Can you e-mail all the files un-fettered files? I bet there isn't as much of a mystery as you might suspect.




Theme © iAndrew 2016 - Forum software by © MyBB