function login_form() { tpl_set('page_description', 'Login'); $arg1 = arg(0); $arg2 = arg(1); $arg3 = arg(2); if ($arg1[0] == "register") { if (!$arg2[0]) { // Initiate a new form. $form = new forms(array('name' => 'register_form', 'method' => 'post', 'action' => '', 'class' => 'register_form form-horizontal', 'id' => 'register-form')); $form->add_field(array('type' => 'text', 'name' => 'name', 'label' => t('Name & Surname'))); $form->add_field(array('type' => 'text', 'name' => 'email', 'label' => t('Email Address'))); $form->add_field(array('type' => 'password', 'name' => 'password', 'label' => t('Password'))); $form->add_field(array('type' => 'password', 'name' => 'password_again', 'label' => t('Password Again'))); // Add a submit button. $form->add_button(array('type' => 'submit', 'name' => 'register_button', 'value' => 'Register', 'class' => 'btn btn-primary')); // And now we deal with validations and submissions. $form->validate('permissions.validate_register_form'); $form->submit('permissions.submit_register_form'); } elseif ($arg2[0] == 2) { $node = new node($arg3); tpl_set('node', objectArray($node)); // Initiate a new form. $form = new forms(array('name' => 'register_form', 'method' => 'post', 'action' => '', 'class' => 'register_form form-horizontal', 'id' => 'register-form')); $form->add_field(array('type' => 'text', 'name' => 'activation_code', 'label' => t('Activation Code'))); // Add a submit button. $form->add_button(array('type' => 'submit', 'name' => 'register_button', 'value' => 'Activate', 'class' => 'btn btn-primary')); // And now we deal with validations and submissions. $form->validate('permissions.validate_activation_form'); $form->submit('permissions.submit_activation_form'); } elseif ($arg2[0] == 3) { header('location: ' . base_path()); } } else { if ($arg1[0] == 'lostpassword') { // Initiate a new form. $form = new forms(array('name' => 'register_form', 'method' => 'post', 'action' => '', 'class' => 'register_form form-horizontal', 'id' => 'register-form')); // Now we start to add some fields. $form->add_field(array('type' => 'text', 'name' => 'email', 'label' => t('Email Address'))); // Add a submit button. $form->add_button(array('type' => 'submit', 'name' => 'register_button', 'value' => 'Retrieve', 'class' => 'btn btn-primary')); // And now we deal with validations and submissions. $form->validate('permissions.validate_login_form'); $form->submit('permissions.submit_login_form'); } else { // Initiate a new form. $form = new forms(array('name' => 'login_form', 'method' => 'post', 'action' => '', 'class' => 'login_form form-horizontal', 'id' => 'login-form')); // Now we start to add some fields. $form->add_field(array('type' => 'text', 'name' => 'username', 'label' => t('Username'))); $form->add_field(array('type' => 'password', 'name' => 'password', 'label' => t('Password'))); // Add a submit button. $form->add_button(array('type' => 'submit', 'name' => 'login_button', 'value' => 'Login', 'class' => 'btn btn-primary')); // And now we deal with validations and submissions. $form->validate('permissions.validate_login_form'); $form->submit('permissions.submit_login_form'); } } // form testing $form->render(); }
function add_contact() { // Initiate a new form. $form = new forms(array('name' => 'create_a_contact', 'method' => 'post', 'action' => '', 'class' => 'create_a_contact_form form-horizontal', 'id' => 'create-a-contact-form')); // Now we start to add some elements. $form->add_field(array('type' => 'text', 'name' => 'title', 'label' => t('Name'), 'placeholder' => t('Enter your contact\'s full name'), 'required' => true)); $form->add_field(array('type' => 'tel', 'name' => 'mobile', 'label' => t('Mobile'), 'placeholder' => t('Enter your contact\'s mobile number'))); $form->add_field(array('type' => 'email', 'name' => 'email', 'label' => t('Email'), 'placeholder' => t('Enter your contact\'s email address'))); // Add a submit button. $form->add_button(array('type' => 'submit', 'name' => 'add_contact', 'value' => 'Add Contact', 'class' => 'btn btn-primary')); // And now we deal with validations and submissions. $form->validate('contacts_add.add_contact_validate'); $form->submit('contacts_add.add_contact_submit'); // form testing $form->render(); }