for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace carono\checksum;
use yii\helpers\Html;
/**
* Trait ActiveFieldTrait
*
* @package carono\checksum
* @mixin \yii\widgets\ActiveField
*/
trait ActiveFieldTrait
{
public function init()
if (\Yii::$app->request instanceof Request && \Yii::$app->request->checksumIsEnabled()) {
if (!$this->form->canGetProperty('_checksumInit')) {
$this->form->attachBehavior('caronoChecksumBehavior', ActiveFormBehavior::className());
form
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
\Yii::$app->request->clearStack($this->form->id);
}
parent::init();
public function __toString()
$string = parent::__toString();
if (preg_match('#<input|<select|<textarea#', $string)) {
$attribute = Html::getAttributeName($this->attribute);
attribute
\Yii::$app->request->stackField($this->form->id, $this->model->formName(), $attribute);
model
return $string;
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: