ajaxCRUD.com

» a PHP class to create / read / update / delete from a database table using AJAX

   by loud canvas media

AjaxCRUD API Reference

<< Reference overview
<< Home

defineAllowableValues

define "allowable" values for a field.
void defineAllowableValues ( String fieldName, String[] allowableValues, [ onedit_textbox = FALSE ] )
These allowable fields will display in a dropdown of the values you specify. You can have the values for the dropdown be the same as the text or separate. Both examples are provided below.

In addition, you can use the third parameter (optional) to allow fields (after being inserted) to NOT have only the allowed values permissable. If set to TRUE then a regular textbox will appear when editing this field--allowing any values.

Details

Type function
Returns void

Parameters

fieldName
The database field name to define allowable values for
allowableValues
The allowed values for that field. Can be array of strings (for value = text) or An array of arrays (where [0] = value and [1] = text)
(optional) onedit_textbox (default: false)
If set to true this value allows the field to not open a dropdown box on EDIT of the field. It will be a textbox allowing any input

Example

With id and value the same


    $allowable_vals   = array("DropdownValue 1", "Dropdown Value2");
    $tblDemo->defineAllowableValues("fldCertainFields", $allowable_vals);

With id and value different


    $allowable_vals = array(array(0 => "ddv1", 1 => "Dropddown Value 1"), 
               array(0 => "ddv2", 1 => "Dropdown Value2");
    $tblDemo->defineAllowableValues("fldCertainFields", $allowable_vals);

See also

New, Edit

 

"Great api. Really love the demo. "
~Ade