Hello everybody. I have a task that I'll be working on a new project.
The project will have credit card details, and user pages for a clients of a bank.
These clients are already registered in the banks database, but now In the new website they'll be able to register and login into the website and see details about their card details, account, status and etc. The bank gave me a PHP class and they said with that file will be able to take info of the users.

The goal is to create a form with three steps. The first one will have 4 fields about card details, last digits, code and transaction date. These fields will have to validate somehow by a PHP class. Does anyone know how to make that kind of validation? Unfortunately I'm beginner with Object oriented programming.
Maybe I'm going in wrong direction, I'm not sure, but any help will be really appreciated.

Comments

chronosinteractive’s picture

You'll want to write a custom module, and hook into a form with your own validation function.

Example form hook:

function yourCustomModule_form_user_profile_form_alter(&$form, &$form_state, $form_id) {
  $form['#validate'][] = 'yourCustom_function_form_validate';
}
function yourCustom_function_form_validate($form, &$form_state) {
// do stuff here
if ($bad) {
	form_set_error('error_name', 'Error show to user, you caused $bad to be true!');
}
}

Basically, you can use hook_form_FORM_ID_alter and add a function to the validation for the form. Then, within that custom form you can anything you want - like call your php class. If you find out something isn't valid, you can then set an error.

satvision83’s picture

Thank you very much. It's working great!