本文整理汇总了PHP中kartik\base\Config::validateInputWidget方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::validateInputWidget方法的具体用法?PHP Config::validateInputWidget怎么用?PHP Config::validateInputWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kartik\base\Config
的用法示例。
在下文中一共展示了Config::validateInputWidget方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderFormAttribute
/**
* Renders each form attribute
*
* @param array $config the attribute config
*
* @return mixed
* @throws \yii\base\InvalidConfigException
*/
protected function renderFormAttribute($config)
{
if (empty($config['attribute'])) {
return '';
}
$model = ArrayHelper::getValue($config, 'editModel', $this->model);
if (!$model instanceof Model) {
$model = $this->model;
}
$attr = ArrayHelper::getValue($config, 'updateAttr', $config['attribute']);
$input = ArrayHelper::getValue($config, 'type', self::INPUT_TEXT);
$fieldConfig = ArrayHelper::getValue($config, 'fieldConfig', []);
$inputWidth = ArrayHelper::getValue($config, 'inputWidth', '');
$container = ArrayHelper::getValue($config, 'inputContainer', []);
if ($inputWidth != '') {
Html::addCssStyle($container, "width: {$inputWidth}");
// deprecated since v1.7.4
}
$template = ArrayHelper::getValue($fieldConfig, 'template', "{input}\n{error}\n{hint}");
$row = Html::tag('div', $template, $container);
if (static::hasGridCol($container)) {
$row = '<div class="row">' . $row . '</div>';
}
$fieldConfig['template'] = $row;
if (substr($input, 0, 8) == "\\kartik\\") {
Config::validateInputWidget($input, 'as an input widget for DetailView edit mode');
} elseif ($input !== self::INPUT_WIDGET && !in_array($input, self::$_inputsList)) {
throw new InvalidConfigException("Invalid input type '{$input}' defined for the attribute '" . $config['attribute'] . "'.");
}
$options = ArrayHelper::getValue($config, 'options', []);
$widgetOptions = ArrayHelper::getValue($config, 'widgetOptions', []);
$class = ArrayHelper::remove($widgetOptions, 'class', '');
if (!empty($config['options'])) {
$widgetOptions['options'] = $config['options'];
}
if (Config::isInputWidget($input)) {
$class = $input;
return $this->_form->field($model, $attr, $fieldConfig)->widget($class, $widgetOptions);
}
if ($input === self::INPUT_WIDGET) {
if ($class == '') {
throw new InvalidConfigException("Widget class not defined in 'widgetOptions' for {$input}'.");
}
return $this->_form->field($model, $attr, $fieldConfig)->widget($class, $widgetOptions);
}
if (in_array($input, self::$_dropDownInputs)) {
$items = ArrayHelper::getValue($config, 'items', []);
return $this->_form->field($model, $attr, $fieldConfig)->{$input}($items, $options);
}
if ($input == self::INPUT_HTML5_INPUT) {
$inputType = ArrayHelper::getValue($config, 'inputType', self::INPUT_TEXT);
return $this->_form->field($model, $attr, $fieldConfig)->{$input}($inputType, $options);
}
return $this->_form->field($model, $attr, $fieldConfig)->{$input}($options);
}
示例2: init
/**
* Initializes the widget
*
* @throws InvalidConfigException
*/
public function init()
{
$this->_msgCat = 'kveditable';
parent::init();
if (empty($this->inputType)) {
throw new InvalidConfigException("The 'type' of editable input must be set.");
}
if (!Config::isValidInput($this->inputType)) {
throw new InvalidConfigException("Invalid input type '{$this->inputType}'.");
}
if ($this->inputType === self::INPUT_WIDGET && empty($this->widgetClass)) {
throw new InvalidConfigException("The 'widgetClass' must be set when the 'inputType' is set to 'widget'.");
}
if (Config::isDropdownInput($this->inputType) && !isset($this->data)) {
throw new InvalidConfigException("You must set the 'data' property for '{$this->inputType}'.");
}
if (!empty($this->formClass) && !class_exists($this->formClass)) {
throw new InvalidConfigException("The form class '{$this->formClass}' does not exist.");
}
Config::validateInputWidget($this->inputType);
$this->initI18N(__DIR__);
$this->initOptions();
$this->_popoverOptions['options']['id'] = $this->options['id'] . '-popover';
$this->_popoverOptions['toggleButton']['id'] = $this->options['id'] . '-targ';
$this->registerAssets();
echo Html::beginTag('div', $this->containerOptions);
if ($this->format == self::FORMAT_BUTTON) {
echo Html::tag('div', $this->displayValue, $this->editableValueOptions);
}
if ($this->asPopover === true) {
PopoverX::begin($this->_popoverOptions);
} elseif ($this->format !== self::FORMAT_BUTTON) {
echo $this->renderToggleButton();
}
echo Html::beginTag('div', $this->contentOptions);
$class = $this->formClass;
$this->_form = $class::begin($this->formOptions);
if (!$this->_form instanceof \yii\widgets\ActiveForm) {
throw new InvalidConfigException("The form class '{$class}' MUST extend from \\yii\\widgets\\ActiveForm.");
}
}
示例3: checkValidFilters
/**
* Checks if the filter input types are valid
*
* @return void
*/
protected function checkValidFilters()
{
if (isset($this->filterType)) {
\kartik\base\Config::validateInputWidget($this->filterType, 'for filtering the grid as per your setup');
}
}
示例4: renderFormAttribute
/**
* Renders each form attribute
*
* @param array $config the attribute config
*
* @return mixed
* @throws \yii\base\InvalidConfigException
*/
protected function renderFormAttribute($config)
{
if (empty($config['attribute'])) {
return '';
}
$attr = ArrayHelper::getValue($config, 'updateAttr', $config['attribute']);
$input = ArrayHelper::getValue($config, 'type', self::INPUT_TEXT);
$fieldConfig = ArrayHelper::getValue($config, 'fieldConfig', []);
$inputWidth = ArrayHelper::getValue($config, 'inputWidth', '');
if ($inputWidth != '') {
$template = ArrayHelper::getValue($fieldConfig, 'template', "{input}\n{error}\n{hint}");
$fieldConfig['template'] = "<div style='width:{$inputWidth};'>{$template}</div>";
}
if (substr($input, 0, 8) == "\\kartik\\") {
Config::validateInputWidget($input, 'as an input widget for DetailView edit mode');
} elseif ($input !== self::INPUT_WIDGET && !in_array($input, self::$_inputsList)) {
throw new InvalidConfigException("Invalid input type '{$input}' defined for the attribute '" . $config['attribute'] . "'.");
}
$options = ArrayHelper::getValue($config, 'options', []);
$widgetOptions = ArrayHelper::getValue($config, 'widgetOptions', []);
$class = ArrayHelper::remove($widgetOptions, 'class', '');
if (!empty($config['options'])) {
$widgetOptions['options'] = $config['options'];
}
if (Config::isInputWidget($input)) {
$class = $input;
return $this->_form->field($this->model, $attr, $fieldConfig)->widget($class, $widgetOptions);
}
if ($input === self::INPUT_WIDGET) {
if ($class == '') {
throw new InvalidConfigException("Widget class not defined in 'widgetOptions' for {$input}'.");
}
return $this->_form->field($this->model, $attr, $fieldConfig)->widget($class, $widgetOptions);
}
if (in_array($input, self::$_dropDownInputs)) {
$items = ArrayHelper::getValue($config, 'items', []);
return $this->_form->field($this->model, $attr, $fieldConfig)->{$input}($items, $options);
}
if ($input == self::INPUT_HTML5_INPUT) {
$inputType = ArrayHelper::getValue($config, 'inputType', self::INPUT_TEXT);
return $this->_form->field($this->model, $attr, $fieldConfig)->{$input}($inputType, $options);
}
return $this->_form->field($this->model, $attr, $fieldConfig)->{$input}($options);
}
示例5: initConfig
/**
* Initializes widget based on module settings
*
* @throws \yii\base\InvalidConfigException
*/
protected function initConfig()
{
$this->_module = Config::initModule(Module::classname());
if (!isset($this->autoWidget)) {
$this->autoWidget = $this->_module->autoWidget;
}
if (!$this->autoWidget && !empty($this->widgetClass) && !class_exists($this->widgetClass)) {
throw new InvalidConfigException("The widgetClass '{$this->widgetClass}' entered is invalid.");
}
if ($this->autoWidget === null) {
$this->autoWidget = true;
}
$this->_widgetSettings = $this->_module->widgetSettings;
if (empty($this->displayFormat)) {
$this->displayFormat = $this->_module->getDisplayFormat($this->type);
} else {
$this->displayFormat = Module::parseFormat($this->displayFormat, $this->type);
}
if (empty($this->saveFormat)) {
$this->saveFormat = $this->_module->getSaveFormat($this->type);
} else {
$this->saveFormat = Module::parseFormat($this->saveFormat, $this->type);
}
if (empty($this->displayTimezone)) {
$this->displayTimezone = $this->_module->getDisplayTimezone();
}
if (empty($this->saveTimezone)) {
$this->saveTimezone = $this->_module->getSaveTimezone();
}
if ($this->autoWidget) {
$this->_widgetSettings = [
self::FORMAT_DATE => ['class' => '\kartik\date\DatePicker'],
self::FORMAT_DATETIME => ['class' => '\kartik\datetime\DateTimePicker'],
self::FORMAT_TIME => ['class' => '\kartik\time\TimePicker'],
];
Config::validateInputWidget($this->_widgetSettings[$this->type]['class'],
"for DateControl '{$this->type}' format");
foreach ($this->_widgetSettings as $type => $setting) {
$this->_widgetSettings[$type]['options'] = $this->_module->autoWidgetSettings[$type];
$this->_widgetSettings[$type]['disabled'] = $this->disabled;
$this->_widgetSettings[$type]['readonly'] = $this->readonly;
}
}
if (empty($this->widgetClass) && !empty($this->_widgetSettings[$this->type]['class'])) {
$this->widgetClass = $this->_widgetSettings[$this->type]['class'];
}
}