12
en/14.3.md
12
en/14.3.md
@@ -23,16 +23,16 @@ For developers, the general development process can be quite complex, but it's m
|
|||||||
|
|
||||||
First, we define a `struct` with fields corresponding to the fields in our form element. We can use `struct` tags which map to the form element, as shown below:
|
First, we define a `struct` with fields corresponding to the fields in our form element. We can use `struct` tags which map to the form element, as shown below:
|
||||||
|
|
||||||
First define a struct that corresponds to when developing Web applications, a field corresponding to a form element, defined by using a struct tag corresponding to the element information and authentication information, as shown below:
|
When developing Web applications, first define a struct that matches a field to a corresponding form element, defined by using a struct tag corresponding to the element information and authentication information, as shown below:
|
||||||
|
|
||||||
For developers, the general development process is very complex, and mostly are repeating the same work. Assuming a scenario project suddenly need to add a form data, then the local code of the entire process needs to be modified. We know that Go inside a struct is a common data structure, so beego the form struct used to process form information.
|
For developers, the general development process is very complex, and mostly consists of repeating the same work process. Assuming a scenario for a project whereby a need arises to add data to a form, then the local code of the entire process needs to be modified. We know in Go a struct is a common data structure, so beego uses a form struct to process form information.
|
||||||
|
|
||||||
First define a `struct` with fields corresponding to our form element, using `struct` tags to define corresponding element and authentication information, like so:
|
First define a `struct` with fields corresponding to our form element, using `struct` tags to define the corresponding form element and authentication information, like so:
|
||||||
|
|
||||||
type User struct{
|
type User struct{
|
||||||
Username string `form:text,valid:required`
|
Username string `form:text,valid:required`
|
||||||
Nickname string `form:text,valid:required`
|
Nickname string `form:text,valid:required`
|
||||||
Age int `form:text,valid:required|numeric`
|
Age int `form:text,valid:required|numeric`
|
||||||
Email string `form:text,valid:required|valid_email`
|
Email string `form:text,valid:required|valid_email`
|
||||||
Introduce string `form:textarea`
|
Introduce string `form:textarea`
|
||||||
}
|
}
|
||||||
@@ -179,7 +179,7 @@ The following table lists some form validation rules native to Beego that can be
|
|||||||
|
|
||||||
<td class="td">Yes</td>
|
<td class="td">Yes</td>
|
||||||
|
|
||||||
<td class="td">if the form element's value with the specified field in a table have duplicate data, it returns False( Translator's
|
<td class="td">if the form element's value with the specified field in a table has duplicate data, it returns False( Translator's
|
||||||
Note: For example is_unique [User.Email], then the validation class will look for the User table in the
|
Note: For example is_unique [User.Email], then the validation class will look for the User table in the
|
||||||
Email field there is no form elements with the same value, such as deposit repeat, it returns false, so
|
Email field there is no form elements with the same value, such as deposit repeat, it returns false, so
|
||||||
developers do not have to write another Callback verification code.)</td>
|
developers do not have to write another Callback verification code.)</td>
|
||||||
@@ -191,7 +191,7 @@ The following table lists some form validation rules native to Beego that can be
|
|||||||
<td class="td"><strong>min_length</strong>
|
<td class="td"><strong>min_length</strong>
|
||||||
</td>
|
</td>
|
||||||
<td class="td">Yes</td>
|
<td class="td">Yes</td>
|
||||||
<td class="td">form element values if the character length is less than the number defined parameters, it returns FALSE</td>
|
<td class="td">form element values if the character length is less than the number of defined parameters, it returns FALSE</td>
|
||||||
<td class="td">min_length [6]</td>
|
<td class="td">min_length [6]</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user