This is the front deskThis is the Cate controller##This is the Model templateThe 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?
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.
null
string
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 emptystring
.