Add fields to a specific meta box

A meta box can have multiple types of item. For this tutorial, you will learn how to create a form with fields and how to embed it to a meta box. First of all,
we'll create form header. It's made using "form_wrap" key on "meta_box" method like this.

<?php
$this->gui->set_meta( array(
  	'type'			=>	'panel',
  	'namespace'	=>	core_meta_namespace( array( 'custom' , 'namespace' ) ), // very useful to create unique namespace
  	'form_wrap'	=>	array(
      	'method'			=>	'post',
      	'submit_text'	=>	__( 'Save Settings' ),
      	'enctype'			=>	'multipart/form_data', // example,
      	'reset_text'	=>	__( 'Reset form' ), // no required.
    )
) )->push_to( 1 ); // here 1 is the col id.

We assume you already know how to set cols width and create meta box using GUI Library.

To create any type of item, you can use "set_item" method of the GUI Library. This method takes an array as parameter. to be valid, this array must have specific key with specific values.

Here what we're talking about.

<?php
$this->gui->set_item( array(
	'type'	=>	'text', // generate input field
  'name'	=>	'custom', // this is the attribute name of that field.
  'label'	=>	__( 'Custom Label' ),
  'placeholder'	=>	__( 'Custom placeholder' ),
  'value'		=>	'', // used to set default value. Very usefull if you let GUI handle you page option.
) )->push_to( 'custom-metabox' ); // don't forget to push it to a valid meta box.

for "type" key, you can use several value such as "password" to generate a password input, "text" to generate text input, "select" for a select option field, "textarea" to generate textarea field, "checkbox" to generate checkbox field, "radio" to generate a radio field, "hidden" to generate hidden field, 'file' to general file field (make sure to change 'enctype' on meta box header).

For "select" type, the key "value" and "text" must be an array (not an associative array), representative of each select option value and texts. Obviously, this array must have the same length.

Here is an example :

<?php
$this->gui->set_item( array(
	'type'	=>	'select',
  'name'	=>	'custom',
  'label'	=>	__( 'Custom Select' ),
  'value'	=>	array( 1 , 2 , 3 , 4 ),
  'text'	=>	array( __( 'First Option' ) , __( 'Second Option' ) , __( 'Third Option' ) , __( 'Fourth Option' ) ),
  'active'	=>	1 // this key let you define active option. Comparision is made using each key value.
) )->push_to( 'custom-metabox' );