php - tp's automatic verification does not work
世界只因有你
世界只因有你 2017-05-27 17:43:50
0
3
482

This is the front desk

This is the Cate controller
##This is the Model template

The problem is that the data can be inserted into the database normally, but it cannot be verified whether it is empty? Please help me find out why?

世界只因有你
世界只因有你

reply all(3)
Ty80

Just check whether I('post.catename') is empty in the controller

刘奇

Is the code in the Cate controller written wrong? . .

$data['catename'] = I('catename'); Is this line wrong?

It should be:
$data['catename'] = I('post.catename');
Let’s do this.

In fact, you don’t need to write it again to get it. The direct create method will get all the data requested by the front desk

Another thing to note is that the create method only accepts post request data by default when you have not modified the underlying code

某草草

I mean, to refute the above, there is no problem with I ("catename"). I forgot the form verification, but you can try the following test

1. Use a custom verification function. You can see whether verification is called (see how the document defines it)

2. Verify the length, because the value obtained by the I() function is not null but an empty string.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template