Field Formular
/String NEW

Set formular on fields. Edit a record, input firstname and see as Assigned Email is generated.

HIDE CODE
<?php
    // Get an instance of the Xcrud class
    $xcrud = Xcrud::get_instance();	

    // Set the table to work with
    $xcrud->table("employees");

    // Define which columns to display in the table
    // These columns will be shown in the table view
    $xcrud->columns("lastName,firstName,extension,email,officeCode");

    // Define which fields are available for data entry or editing
    // These fields will be shown in the form view for adding/editing records
    $xcrud->fields("lastName,firstName,extension,email,officeCode");

    // Set up a relation between the 'officeCode' field in the 'employees' table
    // and the 'officeCode' and 'city' fields in the 'offices' table
    $xcrud->relation("officeCode", "offices", "officeCode", "city");

    // Set up a dynamic formula for the 'email' field
    // When the 'onmouseout' event is triggered on the 'firstName' field,
    // the 'email' field will be populated with a concatenated and lowercased string
    // Format: firstName.toLowerCase() + "." + lastName.toLowerCase() + "@myoffice.com"
    $xcrud->set_formular(
        "email",
        '"{firstName}".toLowerCase() + ".{lastName}@myoffice.com".toLowerCase();',
        "onmouseout",
        "firstName"
    );

    // Make the 'email' field readonly
    // This means the 'email' field cannot be edited by the user
    $xcrud->readonly("email");

    // Change the label of the 'email' field to 'Assigned Email'
    $xcrud->label("email", "Assigned Email");

    // Render the Xcrud instance to display the table and form
    // This will output the HTML needed to display the table and form on the web page
    echo $xcrud->render();	
?>

Employees

#LastnameFirstnameExtensionAssigned EmailOfficecode
Actions
1Firrelli2Jox9273asdjo.firrelli2@myoffice.comLondon View Edit Remove
2Patterson123x4645wpatterson@classicmodelca.comLondon View Edit Remove
3BondurGerard2x540gbondur@classicmodelcars.comNYC View Edit Remove
4BowAnthony8x5428abow@classicmodelcars.comSan Francisco View Edit Remove
5JenningsLesliex540ljennings@classicmodelcars.comTokyo View Edit Remove
6ThompsonLesliex4065lthompson@classicmodelcars.comSan Francisco View Edit Remove
7FirrelliJuliex2173jfirrelli@classicmodelcars.comBoston View Edit Remove
8PattersonStevex4334spatterson@classicmodelcars.comBoston View Edit Remove
9TsengFoon Yueo224ftseng@classicmodelcars.com View Edit Remove
10VanaufGeorge Nx4102gvanauf@classicmodelcars.comNYC View Edit Remove
Search