php codeigniter - 表单助手 - 如何在无线电输入上实现 set_value
我正在使用 codeigniters 表单助手为我的网站设置反馈表单。
我的表单已创建并已实施验证,一切正常。
我唯一的问题是添加 set_value() 函数以在发生错误时重新填充表单。
我无法让它在我的无线电输入上工作,如何将 set_value() 函数添加到无线电类型。
代码:
<ul>
<li><?php echo form_radio('found_by', 'newspaper_advert', set_value('found_by')); ?> Newspaper advert</li>
<li><?php echo form_radio('found_by', 'press_release', set_value('found_by')); ?> Press release</li>
<li><?php echo form_radio('found_by', 'text_message', set_value('found_by')); ?> Text message</li>
<li><?php echo form_radio('found_by', 'email', set_value('found_by')); ?> Email</li>
<li><?php echo form_radio('found_by', 'refferal', set_value('found_by')); ?> Referred to by a friend</li>
<li><?php echo form_radio('found_by', 'telemarketing', set_value('found_by')); ?> Telemarketing</li>
<li><?php echo form_radio('found_by', 'leaflet_flyer', set_value('found_by')); ?> Leaflet or flyer</li>
<li><?php echo form_radio('found_by', 'radio', set_value('found_by')); ?> Radio</li>
<li><?php echo form_radio('found_by', 'television', set_value('found_by')); ?> Television</li>
<li><?php echo form_radio('found_by', 'internet_advert', set_value('found_by')); ?> Internet advert</li>
<li><?php echo form_radio('found_by', 'search_engine', set_value('found_by')); ?> Search engine</li>
<li><?php echo form_radio('found_by', 'none', set_value('found_by')); ?> None of the above</li>
</ul>
I am in the process of setting up a feedback form for my site using codeigniters form helper.
My form has been created and validation implemented, all works.
My only problem is adding the set_value() function to repopulate the form if an error occurs.
I can't get it to work on my radio inputs, how do you add the set_value() function to a radio type.
Code:
<ul>
<li><?php echo form_radio('found_by', 'newspaper_advert', set_value('found_by')); ?> Newspaper advert</li>
<li><?php echo form_radio('found_by', 'press_release', set_value('found_by')); ?> Press release</li>
<li><?php echo form_radio('found_by', 'text_message', set_value('found_by')); ?> Text message</li>
<li><?php echo form_radio('found_by', 'email', set_value('found_by')); ?> Email</li>
<li><?php echo form_radio('found_by', 'refferal', set_value('found_by')); ?> Referred to by a friend</li>
<li><?php echo form_radio('found_by', 'telemarketing', set_value('found_by')); ?> Telemarketing</li>
<li><?php echo form_radio('found_by', 'leaflet_flyer', set_value('found_by')); ?> Leaflet or flyer</li>
<li><?php echo form_radio('found_by', 'radio', set_value('found_by')); ?> Radio</li>
<li><?php echo form_radio('found_by', 'television', set_value('found_by')); ?> Television</li>
<li><?php echo form_radio('found_by', 'internet_advert', set_value('found_by')); ?> Internet advert</li>
<li><?php echo form_radio('found_by', 'search_engine', set_value('found_by')); ?> Search engine</li>
<li><?php echo form_radio('found_by', 'none', set_value('found_by')); ?> None of the above</li>
</ul>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
set_value
仅适用于输入和文本区域。你需要set_radio
从文档页面:http://codeigniter.com/user_guide/helpers/form_helper.html
set_value
only works on inputs and textareas. you needset_radio
From doc page: http://codeigniter.com/user_guide/helpers/form_helper.html
试试这个,它对我有用:
性别:
Try this, It works for me:
Gender:
太容易了......
it is so easy....
这是正确的代码吗?
It is right code in view ??