English 中文(简体)
如何在不按法典要求制定规则的情况下重新接纳一个形式领域?
原标题:How to Repopulate a form field without setting rule as required in Codeigniter?

When I try to populate a form field which is not required in form validation doesn t repopulate. Let s say I have a field but I don t want it to be required but I want it to be repopulated. How can I do it ? I think this is a bug for codeigniter.

最佳回答

这部法典解决了我的问题。 但我必须为此利用助手。 至少我有解决办法。

function value_field($field, $default=  ) {
    return (isset($_POST[$field])) ? $_POST[$field] : $default;
} 
问题回答

你们必须就一个领域制定审定规则,以便重新提出无效的划界案。 简言之,你可以将经常项目设计书的功能,而不仅仅是验证规则,通过<条码>_ 规则(<>>>,因此,你只能设定 >trim<<>>>或某种内容,而不是required

$this->form_validation->set_rules( your_field ,  Your Label ,  trim );

这将重新接纳外地,而不是使其成为必要的领域。

即便是非需要的领域,也使用形式帮助器的定点——价值,我不敢肯定你的问题所在。

echo form_input(array( name  =>  username ,  value  => set_value( username ));




相关问题
PHP Framework: Ebay Like Site

I am going to be builiding a site like ebay - with all the features of ebay. Please note my payment method is limited to paypal. What would be the best PHP framework to use to build this quickly, ...

What s the proper MVC way to do this....?

Quick question about general MVC design principle in PHP, using CodeIgniter or Kohana (I m actually using Kohana). I m new to MVC and don t want to get this wrong... so I m wondering if i have ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Using SimplePie with CodeIgniter and XAMPP

I am using CodeIgniter 1.7.2 with XAMPP 1.7.2 on a Windows computer. I am trying to make use of SimplePie. I followed all the instructions I could find: a copy of simplepie.inc is in my applications/...

CodeIgniter adding semicolons

How do I stop CodeIgniter adding semicolons ; to data sent via POST that contains ampersand &? For example it is converting "a=1&b=2&c=3" into "a=1&b;=2&c;=3". From looking on the forums ...

Best way to make Admin pages in CodeIgniter?

I m working on an app in CodeIgniter, and I want to have admin pages for several of the objects in the application, and I m wondering what would be the better way to put these into an MVC structure. ...

CodeIgniter form verification and class

I m using the form validation library and have something like this in the view <p> <label for="NAME">Name <span class="required">*</span></label> <?...

热门标签