UNA
Loading...
Searching...
No Matches
BxDolForm Class Reference
Inheritance diagram for BxDolForm:
BxDol iBxDolReplaceable BxBaseFormView BxDolStudioForm BxTemplFormView BxTemplFormView BxBaseStudioFormView BxAclFormPrice BxAdsFormOffer BxAdsFormSourcesDetails BxAlbumsFormMedia BxBaseCmtsForm BxBaseFormAccount BxBaseFormConfirmEmail BxBaseFormConfirmPhone BxBaseFormForgotPassword BxBaseFormLogin BxBaseFormProfile BxBaseFormWiki BxBaseLabelForm BxBaseModGeneralFormEntry BxBaseModGroupsFormPrice BxBaseModGroupsFormQuestion BxBaseModTextFormPoll BxBasePrivacyFormGroupCustom BxBaseSearchExtendedForm BxCreditsFormCredit BxDolFormNested BxDolFormNestedGhost BxElsFormManage BxEventsFormSession BxForumFormSearch BxMarketFormLicense BxOAuthFormAdd BxPaymentFormDetails BxPaymentFormInvoices BxPaymentFormView BxShopifyFormSettings BxSnipcartFormSettings BxTasksFormListEntry BxTimelineFormRepost BxAclFormPrice BxAdsFormOffer BxAdsFormSourcesDetails BxAlbumsFormMedia BxBaseCmtsForm BxBaseFormAccount BxBaseFormConfirmEmail BxBaseFormConfirmPhone BxBaseFormForgotPassword BxBaseFormLogin BxBaseFormProfile BxBaseFormWiki BxBaseLabelForm BxBaseModGeneralFormEntry BxBaseModGroupsFormPrice BxBaseModGroupsFormQuestion BxBaseModTextFormPoll BxBasePrivacyFormGroupCustom BxBaseSearchExtendedForm BxCreditsFormCredit BxDolFormNested BxDolFormNestedGhost BxElsFormManage BxEventsFormSession BxForumFormSearch BxMarketFormLicense BxOAuthFormAdd BxPaymentFormDetails BxPaymentFormInvoices BxPaymentFormView BxShopifyFormSettings BxSnipcartFormSettings BxTasksFormListEntry BxTimelineFormRepost

Public Member Functions

 __construct ($aInfo, $oTemplate)
 
 initChecker ($aValues=array(), $aSpecificValues=array())
 
 getKeyValuesPair ()
 
 insert ($aValsToAdd=array(), $isIgnore=false)
 
 update ($val, $aValsToAdd=array(), &$aTrackTextFieldsChanges=null)
 
 isStatusFieldSupported ()
 
 autoSetToPending (&$aValsToAdd)
 
 delete ($val)
 
 generateUri ()
 
 getCleanValue ($sName)
 
 isSubmitted ()
 
 getTemplate ()
 
 getId ()
 
 getName ()
 
 setId ($sId)
 
 setName ($sName)
 
 setAction ($sAction)
 
 setForceSetToPending ($isValid)
 
 setValid ($isValid)
 
 isValid ()
 
 isSubmittedAndValid ()
 
 getSpecificValues ()
 
 setSpecificValue ($sName, $sVal)
 
 getAuthorId ()
 
 setAuthorId ($iAuthorId)
 
 isFieldExist ($sName, $bCheckAllFields=false)
 
 _initCheckerNestedForms ()
 
 addMarkers ($a)
 
 getFormErrors ()
 

Static Public Member Functions

static getObjectInstance ($sObject, $sDisplayName, $oTemplate=false, $sParam='')
 
static unSetObjectInstance ($sObject, $sDisplayName, $oTemplate=false, $sParam='')
 
static getDataItems ($sKey, $isUseForSet=false, $sUseValues=BX_DATA_VALUES_DEFAULT)
 
static getSubmittedValue ($sKey, $sMethod, &$aSpecificValues=false)
 
static setSubmittedValue ($sKey, $mixedValue, $sMethod, &$aSpecificValues=false)
 
static genCsrfToken ($bReturn=false)
 
static getCsrfToken ()
 
static isCsrfTokenValid ($s, $bDeleteToken=true)
 
static onModuleUninstall ($sModuleName)
 
static isVisible ($aInput)
 

Public Attributes

 $aFormAttrs
 
 $aInputs
 
 $aParams
 
 $id
 

Static Public Attributes

static $TYPES_SKIP = array('files' => 1, 'location' => 1, 'nested_form' => 1)
 
static $TYPES_CHECKBOX = array('checkbox' => 1, 'switcher' => 1)
 
static $TYPES_TEXT = array('text' => 1, 'textarea' => 1)
 
static $TYPES_FILE = array('file' => 1)
 
static $FUNC_SKIP_DOMAIN_CHECK = array('email' => 1, 'emails' => 1, 'emailexist' => 1, 'emailuniq' => 1, 'emailexistorempty' => 1, 'hostdomain' => 1, 'hostdomainchat' => 1, 'emailorempty' => 1)
 
static $FUNC_SKIP_MACROS_CHECK = array()
 
static $LOCATION_INDEXES = array ('lat', 'lng', 'country', 'state', 'city', 'zip', 'street', 'street_number')
 
static $LOCATION_INDEXES_MANDATORY = array ('lat', 'lng')
 

Protected Member Functions

 _genMethodName ($s)
 
 _replaceMarkers ($a)
 
 _getPrivacyIcon ($mixedPrivacy)
 
 _getPrivacyGroup ($sPrivacyObject, $iInputId, $iAuthorId=false)
 

Protected Attributes

 $_aMarkers = array ()
 
 $oTemplate
 
 $_isValid = true
 
 $_bForceSetToPending = false
 
 $_sChecker
 
 $_sCheckerHelper
 
 $_aSpecificValues
 
 $_aFieldsCheckForSpam = array()
 
 $_aFieldsExcludeFromCheckForSpam = array()
 
 $_iAuthorId
 
 $_sAuthorKey
 
 $_sPrivacyObjectView
 
 $_sPrivacyGroupDefault
 

Detailed Description

Forms allows to display forms from data stored in DB tables, before it was possible to display forms from PHP arrays only.

The Form Objects have the following main advantages:

  • Minimal coding is needed to create different forms
  • Easy forms alterations
  • Multiple representations of the same form
  • Automated data inserting into database
  • Automated data updating
  • Automated data checking
  • Automatic security checking
  • Automatic spam filter

Forms API uses several definitions:

  • Form or Form Object - record in sys_objects_form table, or instance of Form class.
  • Form Display - set of some form inputs in particular order, displayed for some purpose; one form can have several displays, for example add and edit displays.
  • Form Input or Form Field - form input field, like textarea, checkbox or set of radio buttons.

Creating the Form Object

  1. Create Form Object, add record to sys_objects_form table:
  • object - name of the Form Object, in the format: vendor prefix, underscore, module prefix, underscore, internal identifier or nothing; for example: bx_group - for group data processing, like group adding or editing.
  • title - Form Object title to display in studio forms builder.
  • action - url to submit form to, if url is not full and not empty, then site url is added automatically.
  • form_attrs - serialized array of additional form attributes.
  • submit_name - name of form field with submit button, it is used to determine if form is submitted.
  • table - DB table name (for automatic saving/updating).
  • key - DB table field with unique ID (for automatic updating).
  • uri - DB table field with URI (for automatic URI generation, aling with uri_title).
  • uri_title - DB table field with data title (for automatic URI generation, aling with uri).
  • params - serialized array of additional form parameters:
  • checker_helper - name of custom BxDolFormCheckerHelper class.
  • csrf - array of Cross-site request forgery attack prevention parameters, for now only one boolean parameter is supported - disabled, so it can be disabled for particular form.
  • active - 1 or 0, if form is inactive then it can not be used anywhere.
  • override_class_name - user defined class name which is derived from BxTemplFormView.
  • override_class_file - the location of the user defined class, leave it empty if class is located in system folders.
  1. Create Form Displays, add records to sys_form_displays table:
  • display_name - name of the Form Display, in the format: form object name, underscore, internal identifier or nothing; for example: bx_group_add - for displaying group adding form, bx_group_edit - for displaying group editing form
  • module - module name this display belongs to, it must be associated with name field in sys_modules table.
  • object - form object name from sys_objects_form table this Form Display belongs to.
  • title - Form Display title to display in studio forms builder.
  • view_mode - display form as read-only.
  1. Create Form Fields, add records to sys_form_inputs table:
  • object - form object name from sys_objects_form table this Form Field belongs to.
  • module - module name this field belongs to.
  • name - unique Form Field name in particular From Object.
  • value - default value, or empty if there is no default value.
  • values - possible values, for certain form field types.
  • checked - 0 or 1, it determines if form field is checked, for certain form field types.
  • type - form field type, for now the following types are supported:
    • text - text input field.
    • password - password input field.
    • textarea - multiline input field.
    • number - number input field.
    • select - select one from all available values.
    • select_multiple - select one, multiple or all items from all available values.
    • switcher - on/off switcher.
    • checkbox - one checkbox.
    • checkbox_set - set of checkboxes.
    • radio_set - set of radio buttons.
    • slider - select some numeric value within the range using slider control.
    • doublerange - select range values within the range using slider control.
    • datepicker - date selection control.
    • datetime - date/time selection control.
    • dateselect - date selection control (alternative).
    • captcha - image captcha.
    • hidden - hidden input field.
    • file - file upload input.
    • button - button control.
    • image - form image button.
    • reset - form reset button.
    • submit - form submit button.
    • value - just displaying value without any crontol.
    • block_header - start group of field.
    • custom - custom control.
    • input_set - set of other form controls. detailed description of every type will be described below.
  • caption - input title.
  • info - some info to help user to input data into the field, it's better to specify format and limits here.
  • required - indicate that the input is required by displaying asterisk near the field, please note that this field don't perform any checking automatically, since you mark field as required you need to specify checked function which will check entered value.
  • collapsed - display section as collapsed by default, for block_header field type only.
  • html - display visual editor of certain type, for textarea field type only.
    • 0 - no visual editor, leave textarea field as it is.
    • 1 - standard(default) visual editor,
      See also
      BxDolEditor.
    • 2 - full visual editor,
      See also
      BxDolEditor.
    • 3 - mini visual editor,
      See also
      BxDolEditor.
  • attrs - serialized array of additional input attributes.
  • attrs_tr - serialized array of additional attributes for the whole input row.
  • attrs_wrapper - serialized array of additional attributes for input wrapper.
  • checker_func - checked function, if you marked field as required in textarea field you need to point one of the following checked functions:
    • Length - check value length, additional params must contain min and/or max values for checking.
    • Date - check if date is entered correctly.
    • DateTime - check if datetime is entered correctly.
    • Preg - check value with provided regular expression in checker_params field.
    • Avail - just check if value isn't 0 or empty string, additional function parameters are not used.
    • Email - check if value is written in valid email format.
    • Captcha - check if captcha is entered correctly, for captcha field type only. You can inherit BxDolFormCheckerHelper class and add own checker functions, you will need to point your custom class in Form Object params array.
  • checker_params - serialized array of checker_func parameters.
  • checker_error - error message to show in case of checking function returns false.
  • db_pass - function to pass value through before saving to database and after restoring from database (for example when date need to be converted from/to timestamp value), available values are the following:
    • Int - convert value to integer.
    • Float - convert value to floating point number.
    • Date,DateUtc - convert value to timestamp value before saving to database, and convert from timespamp value after restoring from database.
    • DateTime,DateTimeUtc - convert value to timestamp value before saving to database, and convert from timespamp value after restoring from database.
    • Xss - it warns you that this text can contain XSS vulnerabilities and you need to be extra careful with this, and always use Forms engine to output string to the browser or use bx_process_output if going to output text manually.
    • XssHtml - this text cam have HTML tags, so perform XSS vulnerabilies cleaning before saving to database.
    • All - do not perform any conversion and pass text as it is, be careful with this, use it only when no other function can be used, and make all necessary security checking by yourself.
    • Preg - perform regular expression on the text before saving data to database, regular expression can be provided in db_params field.
    • Boolean - this is used for checkboxes with 'on' value which need to be converted into boolean value.
    • Set - convert set of values into bit integer before saving to database, and restore bit integer into array of values upon restoration from database, it can be used for select_multiple and checkbox_set field types. Please note that values for this field must be 1,2,4,8,... (values of power of 2); the max number of values are 31 for 32bit hardware and 63 for 64bit hardware. You can inherit BxDolFormCheckerHelper class and add own pass functions, you will need to point your custom class in Form Object params array.
  • db_params - serialized array of db_pass parameters.
  • editable - allow to edit this field from admin forms builder.
  • deletable - allow to delete this field from admin forms builder.
  1. Add Form Fields and Form Displays associations, add records to sys_form_display_inputs table:
  • display_name - name of the Form Display from sys_form_displays table.
  • input_name - name of the Form Field from sys_form_inputs table.
  • visible_for_levels - bit field with set of member level ids. To use member level id in bit field the level id minus 1 is used as power of 2, for example:
    • user level id = 1 -> 2^(1-1) = 1
    • user level id = 2 -> 2^(2-1) = 2
    • user level id = 3 -> 2^(3-1) = 4
    • user level id = 4 -> 2^(4-1) = 8
  • active - 1 - form field displayed on form, or 0 - isn't displayed.
  • order - fields are displayed in this order.

Form Field Types

Detailed description of Form Field Types.

Almost all fields have the following common parameters:

  • object
  • name
  • type
  • caption
  • info
  • required
  • attrs
  • attrs_tr
  • attrs_wrapper

We will not describe above list of parameters in every type, since they work the same way for all types.

The list below are field types with their unique parameters, which are designed especially for this field, or some parameters which work differently for the specified field type.

text - text input field. It is displayed as regular single line text input. Parameters:

  • value - default value, or empty if there is no default value.
  • values - not applicable here.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - not applicable here.
  • checker_func Can be used here: Length, Preg, Avail, Email Make no sense to use it here: Date, DateTime, Captcha
  • db_pass Can be used here: Int, Float, Xss, All, Preg Make no sense to use it here: Date, DateTime, XssHtml, Boolean, Set

password - password input field. It is displayed as HTML input element with invisible input. Parameters:

  • value - default value, or empty if there is no default value.
  • values - not applicable here.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - not applicable here.
  • checker_func Can be used here: Length, Preg, Avail. Make no sense to use it here: Date, DateTime, Captcha, Email.
  • db_pass Can be used here: Xss, All. Make no sense to use it here: Int, Float, Date, DateTime, XssHtml, Boolean, Set, Preg.

textarea - multiline input field. It can be displayed as regular textarea field or as visual HTML editor. Parameters:

  • value - default value, or empty if there is no default value.
  • values - not applicable here.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - use visual editor or not.
    • 0 - no visual editor, leave textarea field as it is.
    • 1 - standard(default) visual editor,
      See also
      BxDolEditor.
    • 2 - full visual editor,
      See also
      BxDolEditor.
    • 3 - mini visual editor,
      See also
      BxDolEditor.
  • checker_func Can be used here: Length, Preg, Avail Make no sense to use it here: Email, Date, DateTime, Captcha
  • db_pass Can be used here: Int, Float, Xss, XssHtml, All, Preg Make no sense to use it here: Date, DateTime, Boolean, Set

number - number input field. It is displayed as HTL text input, but with limited width. Also some browsers can add additional controls to this field. Parameters:

  • value - default value, or empty if there is no default value.
  • values - not applicable here.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - not applicable here.
  • checker_func Can be used here: Length, Preg, Avail Make no sense to use it here: Email, Date, DateTime, Captcha
  • db_pass Can be used here: Int, Float Make no sense to use it here: Xss, XssHtml, All, Preg, Date, DateTime, Boolean, Set

select - select one from all available values. It is displayed as HTML combo-box. Parameters:

  • value - default value (array index of selected item from values array), or empty - if there is no default value.
  • values - serialized array of available values, or reference to predefined set of values.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - not applicable here.
  • checker_func Can be used here: Length, Preg, Avail Make no sense to use it here: Email, Date, DateTime, Captcha
  • db_pass Can be used here: Int, Float, Xss, All, Preg Make no sense to use it here: Date, DateTime, XssHtml, Boolean, Set

select_multiple - select one, multiple or all items from all available values. It is displayed as HTML multiple selection input. Parameters:

  • value - default value (bit integer of array indexes of selected items from values array), or empty - if there is no default value.
  • values - serialized array of available values, or reference to predefined set of values. Array index must be power of 2. Max number of values is 31 on 32bit hardware or 63 on 64bit hardware.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - not applicable here.
  • checker_func Can be used here: Length, Preg, Avail Make no sense to use it here: Email, Date, DateTime, Captcha
  • db_pass Can be used here: Int Make no sense to use it here: Float, Xss, All, Preg, Date, DateTime, XssHtml, Boolean, Set

switcher - on/off switcher. It is displayed as custom HTML element with own styles, but on background it works as regular HTML checkbox element. Parameters:

  • value - the value which will be submitted if switcher is on, if switcher is off - nothing is submitted.
  • values - not applicable here.
  • checked - if set to 1 then switcher is on by default, 0 - it is off by default.
  • collapsed - not applicable here.
  • html - not applicable here.
  • checker_func Can be used here: Length, Preg, Avail Make no sense to use it here: Email, Date, DateTime, Captcha
  • db_pass Can be used here: Int, Float, Xss, All, Preg, Boolean Make no sense to use it here: Date, DateTime, XssHtml, Set

checkbox - one checkbox. Displayed as HTML checkbox input element. Parameters:

  • value - the value which will be submitted if checkbox is checked, if checkbox isn't checked - nothing is submitted.
  • values - not applicable here.
  • checked - if set to 1 then checkbox is checked by default, 0 - it is unchecked by default.
  • collapsed - not applicable here.
  • html - not applicable here.
  • checker_func Can be used here: Length, Preg, Avail Make no sense to use it here: Email, Date, DateTime, Captcha
  • db_pass Can be used here: Int, Float, Xss, All, Preg, Boolean Make no sense to use it here: Date, DateTime, XssHtml, Set

checkbox_set - set of checkboxes. It is displayed as set of checkboxes. It is displayed in one row if number of items is equal or less than 3 or every item is displayed on new line if there is more than 3 items in the set. Parameters:

  • value - default value (bit integer of array indexes of selected items from values array), or empty - if there is no default value.
  • values - serialized array of available values, or reference to predefined set of values. Array index must be power of 2. Max number of values is 31 on 32bit hardware or 63 on 64bit hardware.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - not applicable here.
  • checker_func Can be used here: Length, Preg, Avail Make no sense to use it here: Email, Date, DateTime, Captcha
  • db_pass Can be used here: Int Make no sense to use it here: Float, Xss, All, Preg, Date, DateTime, XssHtml, Boolean, Set

radio_set - set of radio buttons. It is displayed as set of radio buttons. It is displayed in one row if number of items is equal or less than 3 or every item is displayed on new line if there is more than 3 items in the set. Parameters:

  • value - default value (array index of selected radio button from values array), or empty - if there is no default value.
  • values - serialized array of available values, or reference to predefined set of values.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - not applicable here.
  • checker_func Can be used here: Length, Preg, Avail Make no sense to use it here: Email, Date, DateTime, Captcha
  • db_pass Can be used here: Int, Float, Xss, All, Preg Make no sense to use it here: Date, DateTime, XssHtml, Boolean, Set

slider - select some numeric value within the range using slider control. It is displayed as jQuery UI HTML control, but on background it works as regular HTML text input element. Parameters:

  • value - default value in the format, or empty if there is no default value.
  • values - not applicable here.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - not applicable here.
  • attrs - the following additional attributes can be used here:
  • min - minimal value, default is 0.
  • max - maximal value, default is 100.
  • step - value can be changed by this step only, default is 1.
  • checker_func Can be used here: Length, Avail Make no sense to use it here: Preg, Email, Date, DateTime, Captcha
  • db_pass Can be used here: Int, Float Make no sense to use it here: Xss, XssHtml, All, Preg, Date, DateTime, Boolean, Set

doublerange - select range values within the range using slider control. Parameters:

  • value - default value in the format [min value]-[max value], for example 16-99, or empty if there is no default value.
  • values - not applicable here.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - not applicable here.
  • attrs - the following additional attributes can be used here:
    • min - minimal value, default is 0.
    • max - maximal value, default is 100.
    • step - value can be changed by this step only, default is 1.
  • checker_func Can be used here: Length, Avail Make no sense to use it here: Preg, Email, Date, DateTime, Captcha
  • db_pass Can be used here: Xss, All, Preg Make no sense to use it here: Int, Float, XssHtml, Date, DateTime, Boolean, Set

datepicker - date selection control. It is displayed as HTML text input control, when clicking on this input then popup with date selector control is appeared. Parameters:

  • value - default value, in the format YYYY-MMM-DD, or empty if there is no default value.
  • values - not applicable here.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - not applicable here.
  • checker_func Can be used here: Date Make no sense to use it here: Length, Preg, Avail, Email, DateTime, Captcha
  • db_pass Can be used here: Date, DateUtc Make no sense to use it here: Int, Float, Xss, All, Preg, DateTime, XssHtml, Boolean, Set

datetime - date/time selection control. Parameters:

  • value - default value, in the format YYYY-MMM-DD HH:MM:SS, or empty if there is no default value.
  • values - not applicable here.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - not applicable here.
  • checker_func Can be used here: DateTime Make no sense to use it here: Length, Preg, Avail, Email, Date, Captcha
  • db_pass Can be used here: DateTime, DateTimeUtc Make no sense to use it here: Int, Float, Xss, All, Preg, Date, XssHtml, Boolean, Set

captcha - image captcha. Displayed as image with some text along with HTML text input for entering displayed on the image text. Parameters:

  • value - not applicable here.
  • values - not applicable here.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - not applicable here.
  • checker_func Can be used here: Captcha Make no sense to use it here: Length, Preg, Avail, Email, Date, DateTime
  • db_pass Can be used here: Xss, All, Preg Make no sense to use it here: Int, Float, Date, DateTime, XssHtml, Boolean, Set

hidden - hidden input field. Displayed as hidden HTML input. Parameters:

  • value - hidden input value.
  • values - not applicable here.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - not applicable here.
  • checker_func Can be used here: Length, Preg, Avail, Email, Date, DateTime Make no sense to use it here: Captcha
  • db_pass Can be used here: Int, Float, Xss, All, Preg, Date, DateUtc, DateTime, DateTimeUtc, XssHtml, Boolean Make no sense to use it here: Set

file - file upload input. Displayed as file upload HTML input. Parameters:

  • value - not applicable here.
  • values - not applicable here.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - not applicable here.
  • checker_func File name is passed for checking. Can be used here: Avail, Length, Preg Make no sense to use it here: Email, Date, DateTime, Captcha
  • db_pass File can't be stored in the database, so this field isn't applicable here.

files - files upload input. Displayed as complex uploading HTML control. This control is too complex to describe it using default set of database fields, you need to use custom class to display this control.

button - button control. Displayes as HTML button element. Parameters:

  • value - translatable button caption.
  • values - not applicable here.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - not applicable here.
  • checker_func - not applicable here.
  • db_pass - not applicable here.

image - form image button. It is displayed as HTML form image input element. Parameters:

  • value - not applicable here.
  • values - not applicable here.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - not applicable here.
  • attrs - the following mandatory attribute must be specified here:
    • src - image URL.
  • checker_func - not applicable here.
  • db_pass - not applicable here.

reset - form reset button. Displayed as HTML form reset input button. By clicking on this button the form is reset to its default state. Parameters:

  • value - translatable button caption.
  • values - not applicable here.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - not applicable here.
  • checker_func - not applicable here.
  • db_pass - not applicable here.

submit - form submit button. Displayed as HTML form submit input button. This button have the primary button style to distinguish it from other buttons. By clicking on this button the form is submitted. Parameters:

  • value - translatable button caption.
  • values - not applicable here.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - not applicable here.
  • checker_func - not applicable here.
  • db_pass - not applicable here.

value - just displaying value without any control. Parameters:

  • value - the value to display.
  • values - not applicable here.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - not applicable here.
  • checker_func - not applicable here.
  • db_pass - not applicable here.

block_header - start group of fields. Displayed as form fields divider with caption - then it can be collapsible or without caption - then it is just divider without any functionality. Parameters:

  • value - not applicable here.
  • values - not applicable here.
  • checked - not applicable here.
  • collapsed - display group of field collapsed by default, 1 - the group is collapsed, 0 - expanded (default value).
  • html - not applicable here.
  • checker_func - not applicable here.
  • db_pass - not applicable here.

custom - custom control. You need custom class to display this control, so the exact used values are determined by particular realisation.

input_set - set of other form controls. Parameters:

  • value - not applicable here.
  • values - comma separated list of field names (by name field) of fields to display here.
  • checked - not applicable here.
  • collapsed - not applicable here.
  • html - not applicable here.
  • checker_func - not applicable here.
  • db_pass - not applicable here.

Using own class for custom behavior

It is possible to provide own class for displaying and processing the form. To do this you need to point it in override_class_name and override_class_file fields in sys_objects_form table. Your custom class must be inherited from BxTemplFormView class or its descendants.

Displaying custom field control

It is possible to leave form field with default caption and override only the form field control. To override some field you need to define the following function:

protected function genCustomInput[field name] ($aInput).

Where [field name] is form field name. For example:

protected function genCustomInputCustom ($aInput) {
return
'r: <input type="text" size="2" value="'.(isset($aInput['value'][0]) ? $aInput['value'][0] : '').'" name="'.$aInput['name'].'[]" />' .
'g: <input type="text" size="2" value="'.(isset($aInput['value'][1]) ? $aInput['value'][1] : '').'" name="'.$aInput['name'].'[]" />' .
'b: <input type="text" size="2" value="'.(isset($aInput['value'][2]) ? $aInput['value'][2] : '').'" name="'.$aInput['name'].'[]" />';
}

Displaying custom field row

Form row consists of caption and control, by default it is displayed with default design and functionality. If you need to display some field with custom header and control you need to declare the following function:

protected function genCustomRow[field name] ($aInput).

Where [field name] is form field name.

Example of usage

Printing the form for adding new record to the database:

$oForm = BxDolForm::getObjectInstance('sample_form_objects', 'sample_form_objects_add'); // get form instance for specified form object and display
if (!$oForm)
die('"sample_form_objects_add" form object or "sample_form_objects_add" display is not defined');
$oForm->initChecker(); // init form checker witout any data - adding new record
if ($oForm->isSubmittedAndValid())
echo 'inserted id: ' . $oForm->insert (); // add new record to the database
echo $oForm->getCode(); // display form
static getObjectInstance($sObject, $sDisplayName, $oTemplate=false, $sParam='')
Definition BxDolForm.php:784

Printing the form for editing existing record in the database:

// $iEditId - ID of edited row, for example from _GET parameter
$sQuery = $oDb->prepare("SELECT * FROM `sample_input_types` WHERE id = ?", $iEditId);
$aRecord = $oDb->getRow();
if (!$aRecord)
die("$iEditId record wasn't found.");
$oForm = BxDolForm::getObjectInstance('sample_form_objects', 'sample_form_objects_edit'); // get form instance for specified form object and display
if (!$oForm)
die('"sample_form_objects_edit" form object or "sample_form_objects_edit" display is not defined');
$oForm->initChecker($aRecord); // init form checker with edited data
if ($oForm->isSubmittedAndValid())
echo 'updated: ' . $oForm->update ($iEditId); // update database
echo $oForm->getCode(); // display form
static getInstance()
Definition BxDolDb.php:115

Example of custom form class and custom checking helper class:

class BxSampleForm extends BxTemplFormView {
public function __construct ($aInfo, $oTemplate = false) {
parent::__construct ($aInfo, $oTemplate);
}
// display input with 'custom' name
protected function genCustomInputCustom ($aInput) {
return
'r: <input type="text" size="2" value="'.(isset($aInput['value'][0]) ? $aInput['value'][0] : '').'" name="'.$aInput['name'].'[]" />' .
'g: <input type="text" size="2" value="'.(isset($aInput['value'][1]) ? $aInput['value'][1] : '').'" name="'.$aInput['name'].'[]" />' .
'b: <input type="text" size="2" value="'.(isset($aInput['value'][2]) ? $aInput['value'][2] : '').'" name="'.$aInput['name'].'[]" />';
}
}
class BxSampleFormCheckerHelper extends BxDolFormCheckerHelper {
protected $_sDiv = ',';
// prepare RBG values to save to the DB
function passRgb ($s) {
if (!is_array($s))
return false;
$sRet = '';
foreach ($s as $k => $v)
$sRet .= (int)trim($v) . $this->_sDiv;
return trim($sRet, $this->_sDiv);
}
// prepare RGB values to output to the screen
function displayRgb ($s) {
return explode($this->_sDiv, $s);
}
}
Definition BxDolForm.php:1663
Definition BxTemplFormView.php:11

The recommended way is to define forms in database, if it is impossible for some reasons you can init form object from array, there is an example:

$aForm = array(
'form_attrs' => array(
'name' => 'form_my',
'method' => 'post',
),
'params' => array (
'db' => array(
'table' => 'table_name', // table name
'key' => 'ID', // key field name
'uri' => 'EntryUri', // uri field name
'uri_title' => 'Title', // title field to generate uri from
'submit_name' => 'submit_form', // some filed name with non empty value to determine if the for was submitted,
in most cases it is submit button name
),
'csrf' => array(
'disable' => true, //if it wasn't set or has some other value then CSRF checking is enabled for current form, take a look at sys_security_form_token_enable to disable CSRF checking completely.
)
),
'inputs' => array(
'Title' => array(
'type' => 'text',
'name' => 'Title', // the same as key and database field name
'caption' => 'Some caption',
'required' => true,
// checker params
'checker' => array (
'func' => 'length', // see BxDolFormCheckerHelper class for all check* functions
'params' => array(3,100),
'error' => 'length must be from 3 to 100 characters',
),
// database params
'db' => array (
'pass' => 'Xss', // do XSS clear before getting this value, see BxDolFormCheckerHelper class for all pass* functions
),
),
'Description' => array(
'type' => 'textarea',
'name' => 'Description', // the same as key and database field name
'caption' => 'Some caption',
'required' => true,
// checker params
'checker' => array (
'func' => 'length',
'error' => 'enter at least 3 characters',
'params' => array(3,64000),
),
'db' => array (
'pass' => 'XssHtml', // do XSS clear, but keep HTML before getting this value
),
),
);

Using of above array:

$oForm = new BxTemplFormView ($aForm);
$oForm->initChecker();
if ($oForm->isSubmittedAndValid ()) {
// add additional vars to database, in this case creation date field is added
$aValsAdd = array (
'Date' => time(),
);
echo 'insert last id: ' . $oForm->insert ($aValsAdd); // insert validated data to database
} else {
echo $oForm->getCode (); // show form
}

Constructor & Destructor Documentation

◆ __construct()

BxDolForm::__construct ( $aInfo,
$oTemplate )

Reimplemented in BxAccntFormAccount, BxAclFormPrice, BxAdsFormCategory, BxAdsFormEntry, BxAdsFormOffer, BxAdsFormPoll, BxAdsFormSourcesDetails, BxAlbumsFormEntry, BxAlbumsFormMedia, BxBaseCmtsForm, BxBaseCmtsReviewsForm, BxBaseFormAccount, BxBaseFormConfirmEmail, BxBaseFormConfirmPhone, BxBaseFormForgotPassword, BxBaseFormLogin, BxBaseFormProfile, BxBaseFormView, BxBaseFormWiki, BxBaseLabelForm, BxBaseModFilesFormEntry, BxBaseModFilesFormUpload, BxBaseModGeneralFormEntry, BxBaseModGroupsFormEntry, BxBaseModGroupsFormPrice, BxBaseModGroupsFormQuestion, BxBaseModProfileFormEntry, BxBaseModTextFormEntry, BxBaseModTextFormPoll, BxBasePrivacyFormGroupCustom, BxBaseSearchExtendedForm, BxBaseSearchExtendedFormCmts, BxBaseStudioFormView, BxClssFormEntry, BxClssFormPoll, BxCnlFormEntry, BxCnvFormEntry, BxCoursesFormEntry, BxCoursesFormPrice, BxCreditsFormBundle, BxCreditsFormCredit, BxCreditsFormProfile, BxDevFormView, BxDolFormNested, BxDolStudioForm, BxDonationsFormType, BxDrupalFormLogin, BxElsFormManage, BxEventsFormEntry, BxEventsFormPrice, BxEventsFormQuestion, BxEventsFormSession, BxFdbFormQuestion, BxFilesFormEntry, BxFilesFormUpload, BxForumFormEntry, BxForumFormPoll, BxForumFormSearch, BxGlsrFormEntry, BxGroupsFormEntry, BxGroupsFormPrice, BxJobsFormEntry, BxJobsFormPrice, BxJobsFormQuestion, BxMarketFormEntry, BxMarketFormLicense, BxMassMailerFormEntry, BxOrgsFormEntry, BxOrgsFormPrice, BxPaymentFormCommissions, BxPaymentFormDetails, BxPaymentFormInvoices, BxPaymentFormView, BxPersonsFormEntry, BxPhotosFormEntry, BxPhotosFormUpload, BxPollsFormEntry, BxPostsFormEntry, BxPostsFormPoll, BxReviewsFormEntry, BxReviewsFormPoll, BxShopifyFormEntry, BxShopifyFormSettings, BxSnipcartFormEntry, BxSnipcartFormSettings, BxSpacesFormEntry, BxSpacesFormPrice, BxStrmFormEntry, BxTasksFormEntry, BxTasksFormListEntry, BxTemplCmtsForm, BxTemplCmtsReviewsForm, BxTemplFormAccount, BxTemplFormConfirmEmail, BxTemplFormConfirmPhone, BxTemplFormForgotPassword, BxTemplFormLogin, BxTemplFormProfile, BxTemplFormView, BxTemplFormView, BxTemplFormWiki, BxTemplPrivacyFormGroupCustom, BxTemplStudioFormView, BxTimelineFormPost, BxTimelineFormRepost, and BxVideosFormEntry.

Member Function Documentation

◆ _replaceMarkers()

BxDolForm::_replaceMarkers ( $a)
protected

Replace provided markers in form array

Parameters
$aform description array
Returns
array where markes are replaced with real values

◆ addMarkers()

BxDolForm::addMarkers ( $a)

Add replace markers. Curently markers are replaced in action, form_attrs fields.

Parameters
$aarray of markers as key => value
Returns
true on success or false on error

Implements iBxDolReplaceable.

◆ getDataItems()

static BxDolForm::getDataItems ( $sKey,
$isUseForSet = false,
$sUseValues = BX_DATA_VALUES_DEFAULT )
static

Get data items array

Parameters
$sKeydata items identifier
$isUseForSetconvert data items keys to use in set fields, make it power of 2 (1,2,4,8,16,etc).
$sUseValuesuse default(BX_DATA_VALUES_DEFAULT) or additional(BX_DATA_VALUES_ADDITIONAL) value titles, if additinal value title is missing default title is used
Returns
data items array

◆ getObjectInstance()

static BxDolForm::getObjectInstance ( $sObject,
$sDisplayName,
$oTemplate = false,
$sParam = '' )
static

Get form object instance by object name

Parameters
$sObjectobject name
Returns
object instance or false on error

◆ initChecker()

BxDolForm::initChecker ( $aValues = array (),
$aSpecificValues = array() )

Hooks:

'system', 'form_check' - hook to override form object after data checking was performed

◆ insert()

BxDolForm::insert ( $aValsToAdd = array(),
$isIgnore = false )

Hooks:

'system', 'form_submitted' - hook to override form object after data was submitted and saved in database

Reimplemented in BxCnvFormEntry.

◆ isFieldExist()

BxDolForm::isFieldExist ( $sName,
$bCheckAllFields = false )

Check if field exists

Parameters
$sNamefield name
$bCheckAllFieldstrue - check all fields; false - all fields except: password, captcha, hidden, file, button, image, reset, submit, block_header, input_set
Returns
true if field exists or false otherwise

◆ isValid()

BxDolForm::isValid ( )

Reimplemented in BxBaseFormAccount.

◆ isVisible()

static BxDolForm::isVisible ( $aInput)
static

Check if form field is visible.

Parameters
$aInputform field array
Returns
boolean

◆ update()

BxDolForm::update ( $val,
$aValsToAdd = array(),
& $aTrackTextFieldsChanges = null )

Hooks:

'system', 'form_submitted' - hook to override form object after data was submitted and saved in database

Reimplemented in BxBaseFormAccount.


The documentation for this class was generated from the following file: