/

Multi-Step Form Wizards

Turn a long create/edit form into a guided, step-by-step wizard over the exact same single save.

form_wizard() - declare one step per call

->form_wizard($fields, $label, $options = []) declares one step; call it once per step, in the order the steps should appear. A wizard is purely a client-side presentation layer over the same single save every other form uses - the Save button only appears on the final step. It is mutually exclusive with ->fields()/->fields_arrange() as the top-level form layout.

$xcrud->form_wizard('firstName,lastName,email', 'Contact Info');
$xcrud->form_wizard('addressLine1,city,postalCode', 'Address', ['desc' => 'Where should we ship?']);
$xcrud->form_wizard('cardNumber,expiry', 'Payment');
ParameterTypeDefaultDescription
$fieldsstring|array-Comma-separated string or array of field names for this step; a field may appear in exactly one step
$labelstring-Step name shown in the progress indicator
$optionsarray[]desc, next, previous - see below
Option keyTypeDescription
descstringA short sentence shown under the step name
nextstringNext-button label just for this step, overriding the global next_label
previousstringPrevious-button label just for this step, overriding the global previous_label

form_wizard_settings() - global appearance

->form_wizard_settings($settings) configures the wizard's overall look and behavior. Call it once, anywhere after the form_wizard() declarations. Any key you omit keeps its default.

$xcrud->form_wizard_settings([
    'progress' => 'step',
    'next_label' => 'Continue',
    'previous_label' => 'Back',
    'done_label' => 'Submit',
    'validate_step' => true,
]);
SettingTypeDefaultDescription
progressstring'step'See the 4 progress styles below
next_labelstring'Next'Forward button text
previous_labelstring'Back'Back button text
done_labelstringThe page's own Save textButton text on the final step's submit action
show_step_numbersbooltrueShow the "Step N of M" / numeric pill
show_step_descbooltrueShow each step's desc under its label
validate_stepbooltrueRun native HTML5 validation before advancing a step, blocking the move if invalid
Progress styleAppearance
stepNumbered "Step N of M" indicators with labels
pillNav-pill buttons with a checkmark on visited steps
barOne horizontal progress bar, filled to the current step
noneNo progress indicator, just Prev/Next

A complete 3-step example

$xcrud = Xcrud::get_instance();
$xcrud->table('customers');
$xcrud->route('customers');

$xcrud->form_wizard('customerName,contactFirstName,contactLastName', 'Company');
$xcrud->form_wizard('addressLine1,city,country,postalCode', 'Address');
$xcrud->form_wizard('phone,creditLimit', 'Account Terms');

$xcrud->form_wizard_settings([
    'progress' => 'pill',
    'done_label' => 'Create Customer',
]);

$xcrud->render();