开发者

CodeIgniter is caching view variable even if I explicitly set it again

I'm using the CodeIgniter PHP framework. I have a simple form that has an $editcode hidden variable that gets sent on form submit. The form submits data to a form processing function which then redisplays the view with the form again, however with the $editcode$ variable changed to a new value.

The problem is that no matter what I do, the value of $editcode remains the same as the original value even after the form is submitted and the view redrawn with a new $editcode variable.

Extract from my view showing how $editcode is included and submitted.

echo form_open('/add', $formattributes);
echo form_hidden('editcode', set_value('editcode', $editcode));
echo form_submit('submit','Submit!',开发者_开发知识库'id="submit"');

The add() function code (the $refreshed_editcode is positively different from the original $editcode that got generated).

...
$data['editcode'] = $refreshed_editcode;
$this->load->view('includes/template', $data);

When the view gets redrawn by the add() function, the $editcode value should be $refreshed_editcode, but instead it's still the original value.

I know CodeIgniter does some caching of variables for nested views, however in this case I am explicitly resending new values for the $editcode variable. What gives?


Try getting rid of the call to set_value. Since the form field is hidden, it really shouldn't give you much benefit anyway, and I suspect that is where the "caching" is happening (If I'm not mistaken that function is part of the form_helpers file and it actually is designed to cache to help re-populate data, but it has been a while since I've used it).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜