Tag Archives: dimension

set_dimension()

set_dimension(mixed $col, int $cols, int $rows) : $this

Set control dimension width and height. Note that this is not the same as set_form_dimension().

It is used with text type only. For column type text, the width is translated to “size”, its height is ignored. for text area, the width is translated to “cols” and height to “rows”

Parameters

mixed $col
  • Database table column name
int $cols
  • If the column is a text box, it’s the size that represents number of characters. If the column is a textarea, it’s the value for cols attribute in textarea.
int $rows
  • Optional. Number of rows in a textarea (only)

Change Form Width and Height

By default the Database Form adjusts its dimension automatically to fit its contained elements. You can also set form width and height manually with set_form_dimension() method, which has two parameters, width and height.

$dbForm = new C_DatabaseForm("SELECT * FROM Employees", "EmployeeID", "Employees");
$dbForm -> set_label("EmployeeID", "Employee ID");
$dbForm -> set_label("LastName", "Last Name");
$dbForm -> set_label("FirstName", "First Name");
$dbForm -> set_label("BirthDay", "DOB");
$dbForm -> set_hide("Extension");
$dbForm -> set_hide("hireDate");
$dbForm -> set_placeholder('Title', 'official job title');
$dbForm -> add_group_header("EmployeeID", "Basic Info");
$dbForm -> add_group_header("Email", "Contact Info");
$dbForm -> add_tooltip("BirthDate", "Enter employee birth date"); // tooltip supports HTML as well
$dbForm -> set_readonly(array('EmployeeID, LastName'));
$dbForm -> set_ctrltype('Notes', 'wysiwyg');
$dbForm -> set_ctrltype("Country", "autocomplete", "SELECT Code, Name FROM Country");
$dbForm -> set_ctrltype("ReportsTo", "select", "SELECT EmployeeID, LastName FROM Employees");
$dbForm -> set_ctrltype('Email', 'email');
$dbForm -> set_ctrltype('Gender', 'radio', 'M:MMM;F:FFF;Y:YYY;Z:ZZZ');
$dbForm -> set_ctrltype('IsActive', 'checkbox', '1:0');  // single key value pair only
$dbForm -> set_ctrltype('Shift', 'checkboxlist', 'Regular:Regular;Gravy Yard:Gravy Yard');
$dbForm -> set_ctrltype('SSN', 'password');
$dbForm -> set_editrule("SSN", "SSN_validate"); // validate format with javascript
$dbForm -> set_maxlength("FirstName", 12);
$dbForm -> set_default('Title', 'N/A');
$dbForm -> set_form_dimension(800, 1200);  // set width and height for entire form
$dbForm -> display();

Live demo