/** * dbTextSelectField::dbTextSelectField() * * Public constructor: create a new dbTextSelectField object * * @param object &$oForm: the form where the TextSelectfield is located on * @param string $sName: the name of the datefield * @param object $oDb: object of the database handler * @param string $sTable: the table to get the fields from * @param mixed $sField: array of string with the name of the field which data we should get * @param string $sExtraSQL: extra SQL statements * @return dbTextSelectField * @access public * @since 22-10-2008 * @author Johan Wiegel */ function dbTextSelectField(&$oForm, $sName, &$oDb, $sTable, $sField, $sExtraSQL = null, $sMask = null) { // generate the query to retrieve the records $sQuery = 'SELECT ' . $sField . ' FROM ' . $oDb->quote($sTable) . ' ' . $sExtraSQL; $this->_aOptions = array(); // execute the query $sql = $oDb->query($sQuery); // query succeeded if ($sql) { while ($row = $oDb->getRecord($sql)) { $this->_aOptions[] = $row[$sField]; } } else { trigger_error("Error, could not retrieve records.<br '. FH_XHTML_CLOSE .'>\n" . "Error message: " . $oDb->getError() . "<br '. FH_XHTML_CLOSE .'>\n" . "Query: " . $sQuery, E_USER_WARNING); } // call the constructor of the selectfield parent::TextSelectField($oForm, $sName, $this->_aOptions); }
/** * FormHandler::textSelectField() * * Creates a textSelectfield on the form * * @param string $title: The title of the field * @param string $name: The name of the field * @param array $aOptions : the options for the select part * @param string $validator: The validator which should be used to validate the value of the field * @param int $size: The size of the field * @param int $maxlength: The allowed max input of the field * @param string $extra: CSS, Javascript or other which are inserted into the HTML tag * @return void * @access public * @author Johan wiegel * @since 22-10-2008 */ function textSelectField($title, $name, $aOptions, $validator = null, $size = null, $maxlength = null, $extra = null) { require_once FH_INCLUDE_DIR . 'fields/class.TextField.php'; require_once FH_INCLUDE_DIR . 'fields/class.TextSelectField.php'; // create the field $fld = new TextSelectField($this, $name, $aOptions); if (!empty($validator)) { $fld->setValidator($validator); } if (!empty($size)) { $fld->setSize($size); } if (!empty($maxlength)) { $fld->setMaxlength($maxlength); } if (!empty($extra)) { $fld->setExtra($extra); } // register the field $this->_registerField($name, $fld, $title); }