English 中文(简体)
准则调整者格罗卡·十字路口
原标题:Codeigniter Grocery Crud update field?
$crud->set_rules( user_password ,  Password ,  trim|required|matches[konfirmpass] );
$crud->set_rules( konfirmpass ,  Konfirmasi Password ,  trim|required );

$crud->callback_edit_field( user_password ,array($this, _user_edit ));
$crud->callback_add_field( user_password ,array($this, _user_edit ));

反馈职能:

function _user_edit(){
    return  <input type="password" name="user_password"/>  Confirmation password* : <input type="password" name="konfirmpass"/> ;   
}

我的问题是,如果只是“密码”而不是空白,如何更新?

最佳回答

I ve installed CI 2.0.3 and GC 1.1.4 to test because at a glance your code looked fine. As it turns out, it is and your code works. I modified the out of the box employees_management method in the examples controller with GC. Added a user_password column to the database and added your code to the controller.

这两部法典都确保密码场相匹配,在提交时不会空洞。

  • Empty results in "The Password field is required"
  • Mismatched results in "The Password field does not match the konfirmpass field."

也许,如果这 t不为你工作,你就应该把整个方法放在你们身上,而不是仅仅放在规则和呼吁上,这样我们才能看到是否有任何其他问题。

“Working”/

<><>Edit>/strong>

在实地工作时,只有经过编辑的密码,你才需要添加。

$crud->callback_before_update( array( $this, update_password  ) );

function update_password( $post ) { 
if( empty( $post[ user_password ] ) ) {
    unset($post[ user_password ], $post[ konfirmpass ]);
}

return $post;
}

然而,这可能意味着,你需要撤销对空话的确认,这取决于发出回响的先后次序(如果在确认书之前或之后重新提出)。 如果在形式验证之前,你也需要打电话到<条码>查询——在_insert(<<>/code>之前,并在两项回程中添加你的确认规则。 插入显然需要<条码>的要求规则,并更新。

Edit 2, Claring Edit 1

在调查后,验证工作先于回击,因此你可以在回击职能中制定验证规则。 为了实现这一点,你需要使用一个叫做getState()的功能,使你能够根据《世界人权宣言》正在采取的行动添加逻辑。

在此情况下,我们只想把密码放在<条码>查询上。 页: 1 a 增长,而不是updating

So in addition to the above callback update_password(), you will need to wrap your form validation rules in a state check.

if( $crud->getState() ==  insert_validation  ) {
    $crud->set_rules( user_password ,  Password ,  trim|required|matches[konfirmpass] );
    $crud->set_rules( konfirmpass ,  Konfirmasi Password ,  trim|required );
}

如果《世界人权宣言》中加入,这将增加验证选择。

问题回答

暂无回答




相关问题
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> <?...

热门标签