Mokoala v4.0

§ Handling Forms » Customizing Your Form

In the previous example we looked at creating a basic form with an email, password and submit field. The MK_Form class renders forms with the most common attributes, however, there will be cases where you want more control over how your forms are handled.

The example below shows you how to create a form with custom attributes.

$settings = array(
	'attributes' => array(
		'method' => 'get',
		'action' => '/login.php',
		'class' => 'narrow'
	)
);

$fields = array(
	'email' => array(
		'label' => 'Email',
		'type' => 'text',
		'validation' => array(
			'email' => array(),
			'instance' => array()
		)
	),
	'password' => array(
		'label' => 'Password',
		'type' => 'text',
		'validation' => array(
			'instance' => array(),
		),
		'attributes' => array(
			'type' => 'password'
		)
	),
	'login' => array(
		'type' => 'submit',
		'attributes' => array(
			'value' => 'Login'
		)
	)
);

$form = new MK_Form($fields);

print $form->render();

The above form would be rendered at follows (The HTML for the fields has been removed for the sake of demonstration):

<form method="get" action="/login.php" class="narrow">

</form>

Authenticating Users

Basic Guides

Handling Forms

Social Sign In

Using the Dashboard

Working With Data

levitra online