validators\BooleanValidator clientValidateAttribute()

clientValidateAttribute() public method Returns the JavaScript needed for performing client-side validation. You may override this method to return the JavaScript validation code if the validator can support client-side validation. The following JavaScript variables are predefined and can be used in the validation code: attribute: an object describing the the attribute being validated. value: the value being validated. messages: an array used to hold the validation error messages for the

Validating Input

Declaring Rules Ad Hoc Validation Creating Validators Client-Side Validation As a rule of thumb, you should never trust the data received from end users and should always validate it before putting it to good use. Given a model populated with user inputs, you can validate the inputs by calling the yii\base\Model::validate() method. The method will return a boolean value indicating whether the validation succeeded or not. If not, you may get the error messages from the yii\base\Model::$errors p

Using template engines

By default, Yii uses PHP as its template language, but you can configure Yii to support other rendering engines, such as Twig or Smarty available as extensions. The view component is responsible for rendering views. You can add a custom template engine by reconfiguring this component's behavior: [ 'components' => [ 'view' => [ 'class' => 'yii\web\View', 'renderers' => [ 'tpl' => [ 'class' => 'yii\smarty\Vi

Uploading Files

Creating Models Rendering File Input Wiring Up Uploading Multiple Files Uploading files in Yii is usually done with the help of yii\web\UploadedFile which encapsulates each uploaded file as an UploadedFile object. Combined with yii\widgets\ActiveForm and models, you can easily implement a secure file uploading mechanism. Creating Models Like working with plain text inputs, to upload a single file you would create a model class and use an attribute of the model to keep the uploaded file insta

twig\ViewRenderer setLexerOptions()

setLexerOptions() public method Sets Twig lexer options to change templates syntax public void setLexerOptions ( $options )$options array @see self::$lexerOptions

twig\ViewRenderer addGlobals()

addGlobals() public method Adds global objects or static classes public void addGlobals ( $globals )$globals array @see self::$globals

twig\ViewRenderer init()

init() public method public void init ( )

twig\ViewRenderer render()

render() public method Renders a view file. This method is invoked by yii\base\View whenever it tries to render a view. Child classes must implement this method to render the given view file. public string render ( $view, $file, $params )$view yii\base\View The view object used for rendering the file. $file string The view file. $params array The parameters to be passed to the view file. return string The rendering result

twig\ViewRenderer addFunctions()

addFunctions() public method Adds custom functions public void addFunctions ( $functions )$functions array @see self::$functions

twig\ViewRenderer addFallbackPaths()

addFallbackPaths() protected method (available since version 2.0.5) Adds fallback paths to twig loader protected void addFallbackPaths ( $loader, $theme )$loader \Twig_Loader_Filesystem $theme yii\base\Theme|null