How To | 03. Admin Forms

03. Admin Forms

How to create an Admin Form:

  1. Click New Admin Form button on the dashboard:
  2. Choose the Post Type to which the form will be associated:
  3. Then Admin Form's name and the label will be generated and filled automatically, but you can also edit it

How to add fields into Admin Forms

All Admin Form's fields have to be placed in special groups. There is one necessary group called "Main Form Fields" - the group that hosts the standard WordPress fields. This group adds automatically. All the other fields added in the Main Form Fields group will not be displayed in WordPress.

To create another group:

  1. Click Add Group button
  2. Enter group’s name (must be unique for all fields and groups of the form being edited) and label
  3. Now you can add fields only inside the group by clicking the Add field button inside of created group:

Note:

  • You must specify the field name (name), which is selected from a list of names of class properties (for example, the post type) associated with the form. Fields with some controls may not be associated with properties, such as buttons. For such fields, you can specify an arbitrary name that does not match the property names of the associated class and is unique within the form.
  • Name of the field (label) - which will be the sign to the field. Field description (description). Control. By default, you specify a control String that corresponds to a simple text field. However, depending on the type of property that the field is associated with, you can select other control options that will be used in the form to retrieve data from the user for the selected property. Required. If the checkbox is selected, the field is required and the form will not be saved, the user will not fill in this field.
There are several built-in fields for the post Type:
  • post_title - the title of the post
  • post_content - the text of the post
  • post_excerpt - quote
  • thumbnail - thumbnail image
  • post_date - the creation date of the post
These fields are related to the corresponding post properties. To use them, you must add them as properties with the appropriate names when describing the post Type. In the form, they can be added as well as any other fields.

Displaying the Admin Form in WordPress:

Once you have created an Admin Form and uploaded the generated plugin to your site, this form will appear in WordPress while you editing Admin list's column:

  1. Go to your created Admin List:
  2. Click the edit column button:
  3. There you can find your Admin Form and edit it: