Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • None
  • system
    • base
    • caching
    • console
    • db
      • ar
      • schema
    • validators
    • web
      • actions
      • auth
      • helpers
      • widgets
        • captcha
        • pagers
  • zii
    • widgets
      • grid

Classes

  • X2Html
  • Overview
  • Package
  • Class
  • Tree

Class X2Html

CHtml is a static class that provides a collection of helper methods for creating HTML views.

Nearly all of the methods in this class allow setting additional html attributes for the html tags they generate. You can specify for example. 'class', 'style' or 'id' for an html element. For example when using <span class="php-keyword1">array</span>(<span class="php-quote">'class'</span> => <span class="php-quote">'my-class'</span>, <span class="php-quote">'target'</span> => <span class="php-quote">'_blank'</span>) as htmlOptions it will result in the html attributes rendered like this: <span class="php-keyword1">class</span>=<span class="php-quote">"my-class"</span> target=<span class="php-quote">"_blank"</span>.

CHtml
Extended by X2Html
Package: system\web\helpers
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/protected/components/X2Html.php
Methods summary
public static
# sanitizeAttribute( mixed $value )
public static
# clearfix( )
public static
# openBodyTag( mixed $preferences, array $htmlOptions = array () )
public static
# renderPhoneLink( mixed $phoneNumber )
public static
# renderEmailLink( mixed $emailAddress )
public static
# renderSkypeLink( mixed $skypeUser )
public static
# loadingIcon( array $htmlOptions = array () )

renders a loading gif at the center of the screen (to center it within an element, add position: relative to one of its parents.

renders a loading gif at the center of the screen (to center it within an element, add position: relative to one of its parents.

Parameters

$htmlOptions
array
$htmlOptions
public static string
# encode( string $text )

Safeguarded override of CHtml::encode()

Safeguarded override of CHtml::encode()

Converts the text's encoding to avoid "invalid multibyte sequence" errors

Parameters

$text
string
$text data to be encoded

Returns

string
the encoded data

Overrides

CHtml::encode()
public static
# getFlashes( )

Returns html for error, success, and notice flashes.

Returns html for error, success, and notice flashes.

public static type
# hint( type $text, type $superScript = true, type $id = null, type $brackets = false, type $encode = true )

Provides a way to add a '?' with a tooltip to show users how to use the app

Provides a way to add a '?' with a tooltip to show users how to use the app

Parameters

$text
type
$text
$superScript
type
$superScript
$id
type
$id
$brackets
type
$brackets
$encode
type
$encode

Returns

type
public static
# hint2( mixed $title, mixed $htmlOptions = array (), mixed $encode = true )
public static
# mergeHtmlOptions( mixed $optsA, mixed $optsB )
public static string
# settingsButton( string $alt = '', array $htmlOptions )

Generates a settings button

Generates a settings button

Parameters

$alt
string
$alt the image alt
$htmlOptions
array
$htmlOptions options to be applied to the settings button

Returns

string
public static
# renderPageTitle( string $pageTitle, array $htmlOptions = array () )

Renders main content page title

Renders main content page title

Parameters

$pageTitle
string
$pageTitle
$htmlOptions
public static string
# dropDownList( string $name, string $select, array $data, array $htmlOptions = array() )

Modified so that overridden listOptions method is called This method is Copyright (c) 2008-2014 by Yii Software LLC http://www.yiiframework.com/license/

Modified so that overridden listOptions method is called This method is Copyright (c) 2008-2014 by Yii Software LLC http://www.yiiframework.com/license/

Parameters

$name
string
$name the input name
$select
string
$select the selected value
$data
array
$data data for generating the list options (value=>display). You may use CHtml::listData() to generate this data. Please refer to X2Html::listOptions() on how this data is used to generate the list options. Note, the values and labels will be automatically HTML-encoded by this method.
$htmlOptions
array
$htmlOptions additional HTML attributes. Besides normal HTML attributes, a few special attributes are recognized. See CHtml::clientChange() and CHtml::tag() for more details. In addition, the following options are also supported specifically for dropdown list:
  • encode: boolean, specifies whether to encode the values. Defaults to true.
  • prompt: string, specifies the prompt text shown as the first list option. Its value is empty. Note, the prompt text will NOT be HTML-encoded.
  • empty: string, specifies the text corresponding to empty selection. Its value is empty. The 'empty' option can also be an array of value-label pairs. Each pair will be used to render a list option at the beginning. Note, the text label will NOT be HTML-encoded.
  • options: array, specifies additional attributes for each OPTION tag. The array keys must be the option values, and the array values are the extra OPTION tag attributes in the name-value pairs. For example, <pre> array( 'value1'=>array('disabled'=>true,'label'=>'value 1'), 'value2'=>array('label'=>'value 2'), ); </pre>
Since 1.1.13, a special option named 'unselectValue' is available. It can be used to set the value that will be returned when no option is selected in multiple mode. When set, a hidden field is rendered so that if no option is selected in multiple mode, we can still obtain the posted unselect value. If 'unselectValue' is not set or set to NULL, the hidden field will not be rendered.

Returns

string
the generated drop down list

Overrides

CHtml::dropDownList()
public static string
# activeDropDownList( CModel $model, string $attribute, array $data, array $htmlOptions = array() )

Modified so that overridden listOptions method is called This method is Copyright (c) 2008-2014 by Yii Software LLC http://www.yiiframework.com/license/

Modified so that overridden listOptions method is called This method is Copyright (c) 2008-2014 by Yii Software LLC http://www.yiiframework.com/license/

Parameters

$model
CModel
$model the data model
$attribute
string
$attribute the attribute
$data
array
$data data for generating the list options (value=>display) You may use CHtml::listData() to generate this data. Please refer to X2Html::listOptions() on how this data is used to generate the list options. Note, the values and labels will be automatically HTML-encoded by this method.
$htmlOptions
array
$htmlOptions additional HTML attributes. Besides normal HTML attributes, a few special attributes are recognized. See CHtml::clientChange() and CHtml::tag() for more details. In addition, the following options are also supported:
  • encode: boolean, specifies whether to encode the values. Defaults to true.
  • prompt: string, specifies the prompt text shown as the first list option. Its value is empty. Note, the prompt text will NOT be HTML-encoded.
  • empty: string, specifies the text corresponding to empty selection. Its value is empty. The 'empty' option can also be an array of value-label pairs. Each pair will be used to render a list option at the beginning. Note, the text label will NOT be HTML-encoded.
  • options: array, specifies additional attributes for each OPTION tag. The array keys must be the option values, and the array values are the extra OPTION tag attributes in the name-value pairs. For example, <pre> array( 'value1'=>array('disabled'=>true,'label'=>'value 1'), 'value2'=>array('label'=>'value 2'), ); </pre>
Since 1.1.13, a special option named 'unselectValue' is available. It can be used to set the value that will be returned when no option is selected in multiple mode. When set, a hidden field is rendered so that if no option is selected in multiple mode, we can still obtain the posted unselect value. If 'unselectValue' is not set or set to NULL, the hidden field will not be rendered.

Returns

string
the generated drop down list

Overrides

CHtml::activeDropDownList()
public static string
# listOptions( mixed $selection, array $listData, array & $htmlOptions )

Modified to specially handle opt groups This method is Copyright (c) 2008-2014 by Yii Software LLC http://www.yiiframework.com/license/

Modified to specially handle opt groups This method is Copyright (c) 2008-2014 by Yii Software LLC http://www.yiiframework.com/license/

Parameters

$selection
mixed
$selection the selected value(s). This can be either a string for single selection or an array for multiple selections.
$listData
array
$listData the option data (see CHtml::listData())
$htmlOptions
array
$htmlOptions additional HTML attributes. The following two special attributes are recognized:
  • encode: boolean, specifies whether to encode the values. Defaults to true.
  • prompt: string, specifies the prompt text shown as the first list option. Its value is empty. Note, the prompt text will NOT be HTML-encoded.
  • empty: string, specifies the text corresponding to empty selection. Its value is empty. The 'empty' option can also be an array of value-label pairs. Each pair will be used to render a list option at the beginning. Note, the text label will NOT be HTML-encoded.
  • options: array, specifies additional attributes for each OPTION tag. The array keys must be the option values, and the array values are the extra OPTION tag attributes in the name-value pairs. For example, <pre> array( 'value1'=>array('disabled'=>true,'label'=>'value 1'), 'value2'=>array('label'=>'value 2'), ); </pre>
  • key: string, specifies the name of key attribute of the selection object(s). This is used when the selection is represented in terms of objects. In this case, the property named by the key option of the objects will be treated as the actual selection value. This option defaults to 'primaryKey', meaning using the 'primaryKey' property value of the objects in the selection. This option has been available since version 1.1.3.

Returns

string
the generated list options

Overrides

CHtml::listOptions()
public static
# activeMultiTypeAutocomplete( CModel $model, mixed $typeAttribute, mixed $idAttribute, mixed $options, array $config = array () )
public static string
# activeDatePicker( CModel $model, string $attribute, array $htmlOptions = array (), mixed $mode = 'date', array $options = array () )

Parameters

$model
CModel
$model
$attribute
string
$attribute
$htmlOptions
array
(optional) $htmlOptions
$mode
$options

Returns

string
public static
# ul( mixed $listContents, mixed $htmlOptions = array(), mixed $itemClass = '' )
Create a
  • items from an array
Create a
  • items from an array

Parameters

$listContents
mixed
$listContents array of list item attributes to add to the list The 'content' key in the array will be put on the inside of the tag rather than be an attribute
$htmlOptions
mixed
$htmlOptions html attributes to be given to the
    $itemClass
    mixed
    $itemClass a class to add to all of the list Items
    public static
    # popUpDropDown( mixed $list, mixed $htmlOptions = array() )
    public static string
    # fa( string $iconClass, array $htmlOptions = array(), string $content = ' ', mixed $tag = 'i' )

    Create an font awesome icon tag

    Create an font awesome icon tag

    Parameters

    $iconClass
    string
    $iconClass Name of icon such as 'fa-edit' or 'copy' (with or without fa)
    $htmlOptions
    array
    $htmlOptions extra options to be passed to the tag
    $content
    string
    $optional content to be passed inside of the tag (not recommended)
    $tag

    Returns

    string
    generated html content
    public static string
    # x2icon( string $iconClass, array $htmlOptions = array(), string $content = ' ' )

    Create an custom icon tag

    Create an custom icon tag

    Parameters

    $iconClass
    string
    $iconClass name of icon such as 'contact' or 'activity'
    $htmlOptions
    array
    $htmlOptions extra options to be passed to the tag
    $content
    string
    $optional content to be passed inside of the tag (not recommended)

    Returns

    string
    generated html content
    public static
    # IEBanner( mixed $ver = 9, mixed $echo = true )
    public static
    # emailFormButton( )
    public static
    # editRecordButton( mixed $model )
    public static
    # inlineEditButtons( )

    Deprecated. Inline buttons are in the form now.

    Deprecated. Inline buttons are in the form now.

    public static
    # addErrorCss( array & $htmlOptions )

    Appends CHtml::$errorCss to the 'class' attribute.

    Appends CHtml::$errorCss to the 'class' attribute.

    Parameters

    $htmlOptions
    array
    $htmlOptions HTML options to be modified

    Overrides

    CHtml::addErrorCss()
    public static
    # quoteIcon( )
    public static
    # activeRichTextArea( CModel $model, mixed $attribute, array $htmlOptions = array () )
    public static
    # activeCodeEditor( CModel $model, mixed $attribute, array $htmlOptions = array () )
    public static
    # minimizeButton( array $htmlOptions = array (), mixed $hideableSelector = null, mixed $left = true, mixed $defaultOpen = false )
    public static string
    # css( string $text, string $media = '', array $htmlOptions = array () )

    This method is Copyright (c) 2008-2014 by Yii Software LLC http://www.yiiframework.com/license/

    This method is Copyright (c) 2008-2014 by Yii Software LLC http://www.yiiframework.com/license/

    Parameters

    $text
    string
    $text the CSS content
    $media
    string
    $media the media that this CSS should apply to.
    $htmlOptions

    Returns

    string
    the CSS properly enclosed

    Overrides

    CHtml::css()
    public static
    # dynamicDate( mixed $date )
    public static
    # divider( string $width = '100%', string $margin = '15px' )

    Echos a divider useful for custom forms. Example usage in webform creator

    Echos a divider useful for custom forms. Example usage in webform creator

    Parameters

    $width
    string
    $width width of divider
    $margin
    string
    $margin Margin on either side of element
    public static
    # defaultAvatar( mixed $size = '' )

    Echos the default avatar for a profile

    Echos the default avatar for a profile

    public static
    # csrfToken( )

    Returns an input with the CSRF Token

    Returns an input with the CSRF Token

    public static
    # logo( mixed $type, array $htmlOptions = array () )
    public static
    # x2ActivePasswordField( CModel $model, mixed $attr, array $htmlOptions = array (), mixed $enableVisibilityToggle = false )
    public static
    # orderedList( array $items, array $htmlOptions = array () )
    public static
    # unorderedList( array $items, array $htmlOptions = array () )
    public static
    # fragmentTarget( mixed $id )

    Creates fragment targets which are offset by a little more than the height of the top menu. Allows you to link inside documents without having the top of the section you're linking to cut off.

    Creates fragment targets which are offset by a little more than the height of the top menu. Allows you to link inside documents without having the top of the section you're linking to cut off.

    public static array
    # encodeArray( array $arr )

    Encodes special characters in an array of strings into HTML entities. Both the array keys and values will be encoded if needed. If a value is an array, this method will also encode it recursively. The CApplication::charset application charset will be used for encoding.

    Encodes special characters in an array of strings into HTML entities. Both the array keys and values will be encoded if needed. If a value is an array, this method will also encode it recursively. The CApplication::charset application charset will be used for encoding.

    Parameters

    $arr
    array
    $data data to be encoded

    Returns

    array
    the encoded data

    See

    http://www.php.net/manual/en/function.htmlspecialchars.php

    Overrides

    CHtml::encodeArray()
    public static
    # resolveId( CModel $model, mixed $attr )
    Methods inherited from CHtml
    activeCheckBox(), activeCheckBoxList(), activeColorField(), activeDateField(), activeDateTimeField(), activeDateTimeLocalField(), activeEmailField(), activeFileField(), activeHiddenField(), activeId(), activeInputField(), activeLabel(), activeLabelEx(), activeListBox(), activeName(), activeNumberField(), activePasswordField(), activeRadioButton(), activeRadioButtonList(), activeRangeField(), activeSearchField(), activeTelField(), activeTextArea(), activeTextField(), activeTimeField(), activeUrlField(), activeWeekField(), ajax(), ajaxButton(), ajaxLink(), ajaxSubmitButton(), asset(), beginForm(), button(), cdata(), checkBox(), checkBoxList(), clientChange(), closeTag(), colorField(), cssFile(), dateField(), dateTimeField(), dateTimeLocalField(), decode(), emailField(), endForm(), error(), errorSummary(), fileField(), form(), getIdByName(), hiddenField(), htmlButton(), image(), imageButton(), inputField(), label(), link(), linkButton(), linkTag(), listBox(), listData(), mailto(), metaTag(), modelName(), normalizeUrl(), numberField(), openTag(), pageStateField(), passwordField(), radioButton(), radioButtonList(), rangeField(), refresh(), renderAttributes(), resetButton(), resolveName(), resolveNameID(), resolveValue(), script(), scriptFile(), searchField(), setModelNameConverter(), statefulForm(), submitButton(), tag(), telField(), textArea(), textField(), timeField(), urlField(), value(), weekField()
    Constants inherited from CHtml
    ID_PREFIX
    Properties inherited from CHtml
    $afterRequiredLabel, $beforeRequiredLabel, $closeSingleTags, $count, $errorContainerTag, $errorCss, $errorMessageCss, $errorSummaryCss, $liveEvents, $renderSpecialAttributesValue, $requiredCss
    X2CRM Documentation API documentation generated by ApiGen 2.8.0