%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php
/**
* @package yii2-builder
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2022
* @version 1.6.9
*/
namespace kartik\builder;
use yii\base\InvalidConfigException;
use yii\base\Model;
use kartik\form\ActiveForm;
/**
* FormTrait contains common methods for use in [[BaseForm]] builder widget in `yii2-builder`. These methods are also used by
* the [[Form]] and [[TabularForm]] widgets.
*
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @since 1.0
*/
trait FormTrait
{
/**
* Checks base configuration and throws a configuration exception if invalid.
*
* @throws InvalidConfigException
*/
protected function checkBaseConfig()
{
if (empty($this->form) && empty($this->formName)) {
throw new InvalidConfigException(
"The 'formName' property must be set when you are not using with ActiveForm."
);
}
if (!empty($this->form) && !$this->form instanceof ActiveForm) {
throw new InvalidConfigException(
"The 'form' property must be an instance of '\\kartik\\widgets\\ActiveForm' or '\\kartik\\form\\ActiveForm'."
);
}
if (empty($this->attributes)) {
throw new InvalidConfigException("The 'attributes' array must be set.");
}
}
/**
* Checks the form configuration and throws a configuration exception if invalid.
*
* @throws InvalidConfigException
*/
protected function checkFormConfig()
{
if (!$this->hasModel() && empty($this->formName)) {
throw new InvalidConfigException(
"Either the 'formName' has to be set or a valid 'model' property must be set extending from '\\yii\\base\\Model'."
);
}
if (empty($this->formName) && (empty($this->form) || !$this->form instanceof ActiveForm)) {
throw new InvalidConfigException(
"The 'form' property must be set and must be an instance of '\\kartik\\form\\ActiveForm'."
);
}
}
/**
* Check if a valid model is set for the object instance.
*
* @return boolean whether there is a valid model set.
*/
protected function hasModel()
{
return isset($this->model) && $this->model instanceof Model;
}
}