本文整理汇总了PHP中yii\widgets\InputWidget::run方法的典型用法代码示例。如果您正苦于以下问题:PHP InputWidget::run方法的具体用法?PHP InputWidget::run怎么用?PHP InputWidget::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\widgets\InputWidget
的用法示例。
在下文中一共展示了InputWidget::run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
function run()
{
parent::run();
$wid = $this->options['id'];
echo Html::activeHiddenInput($this->model, $this->attribute);
echo Html::beginTag('div', ['id' => $wid . '-buttons', 'class' => 'input-group btn-group']);
$items = PublishBehavior::getPublishedOptions();
$colors = PublishBehavior::getPublishedColors();
foreach ($items as $key => $item) {
echo Html::button($item, ['data' => ['value' => $key], 'class' => $key == $this->model->{$this->attribute} ? 'btn btn-' . $colors[$key] . ' active' : 'btn btn-default']);
}
echo Html::endTag('div');
$js_colors = Json::encode($colors);
$js = <<<JS
\$('#{$wid}-buttons').find('button').each(function(){
\$(this).on('click',function(){
\$('#{$wid}-buttons').find('button').each(function(){
\$(this).removeClass('btn-danger btn-warning btn-success btn-info active');
\$(this).addClass('btn-default');
});
var color={$js_colors};
\$(this).removeClass('btn-default');
\$(this).addClass('btn-'+color[\$(this).data('value')]+' active');
\$('#{$wid}').val(\$(this).data('value'))
});
});
JS;
$this->view->registerJs($js);
}
示例2: run
/**
* @inheritdoc
*/
public function run()
{
parent::run();
if ($this->hasModel()) {
echo Html::activeTextInput($this->model, $this->attribute, $this->options);
} else {
echo Html::textInput($this->name, $this->value, $this->options);
}
$this->registerPlugin();
}
示例3: run
/**
* {@inheritDoc}
* @see \yii\base\Widget::run()
*/
public function run()
{
if (isset($this->options['disabled'])) {
$this->disabled = true;
}
$this->applyPluginSettings();
parent::run();
if (method_exists($this, 'renderWidget')) {
$this->renderWidget();
}
}
示例4: run
public function run()
{
// echo '<table class="table table-bordered">';
// foreach ($this->view->params[$this->name] as $item) {
// echo '<tr>';
// foreach($item as $value) {
// echo '<td>';
// echo $value;
// echo '</td>';
// }
// echo '</tr>';
// }
// echo '</table>';
parent::run();
}
示例5: run
public function run()
{
echo '<table class="table table-bordered">';
foreach ($this->view->params[$this->name] as $item) {
echo '<tr>';
if (is_array($item)) {
foreach ($item as $value) {
echo '<td>';
echo $value;
echo '</td>';
}
} else {
echo $item;
}
echo '</tr>';
}
echo '</table>';
parent::run();
}
示例6: run
public function run()
{
parent::run();
DateTimePickerAsset::register($this->view);
echo $this->renderInput();
if ($this->renderIcon) {
echo $this->renderIcon;
}
$js = 'jQuery(\'#' . $this->getId() . '\').datetimepicker(' . Json::encode($this->getClientOptions()) . ');';
if ($this->renderIcon) {
$js .= 'jQuery(\'#' . $this->getId() . '\').next().on(\'click\', function(){
var $input = jQuery(\'#' . $this->getId() . '\');
if(!$input.attr(\'disabled\') && !$input.attr(\'readonly\')){
$input.datetimepicker(\'show\');
}
return false;
});';
}
$this->view->registerJs($js);
}
示例7: run
public function run()
{
parent::run();
echo Html::beginTag($tag = ArrayHelper::remove($this->options, 'tag', 'div'), $this->options);
echo Html::beginTag($listTag = ArrayHelper::remove($this->listOptions, 'tag', 'div'), $this->listOptions);
if ($values = $this->hasModel() ? $this->model->{$this->attribute} : $this->value) {
foreach ($values as $key => $value) {
echo $this->renderItem($key, $value);
}
} else {
echo $this->renderItem(null, null);
}
echo Html::endTag($listTag);
if (is_callable($this->addLinkOptions)) {
echo call_user_func($this->addLinkOptions, $this->renderItem(null, null), $this);
} else {
Html::addCssClass($this->addLinkOptions, $this->addLinkClass());
$this->addLinkOptions['data-sample-item'] = $this->renderItem(null, null);
echo Html::a(Html::tag('span', '', ['class' => 'glyphicon glyphicon-plus']) . self::t('multistring', 'Add...'), '#', $this->addLinkOptions);
}
echo Html::endTag($tag);
$this->view->registerJs('jQuery(\'#' . $this->getId() . '\').multiString(' . Json::encode($this->clientOptions) . ')');
}
示例8: run
/**
* Run widget
*/
public function run()
{
parent::run();
if (!isset($this->wrapperOptions)) {
$this->wrapperOptions = [];
}
if (!isset($this->wrapperOptions['id'])) {
$this->wrapperOptions['id'] = $this->id;
}
if (!isset($this->wrapperOptions['style'])) {
$this->wrapperOptions['style'] = 'width: 100%; height: 500px;';
}
SelectMapLocationAssets::$googleMapApiKey = $this->googleMapApiKey;
SelectMapLocationAssets::register($this->view);
// getting inputs ids
$address = Html::getInputId($this->model, $this->attribute);
$latitude = Html::getInputId($this->model, $this->attributeLatitude);
$longitude = Html::getInputId($this->model, $this->attributeLongitude);
$jsOptions = ArrayHelper::merge($this->jsOptions, ['address' => '#' . $address, 'latitude' => '#' . $latitude, 'longitude' => '#' . $longitude, 'draggable' => $this->draggable]);
// message about not founded addess
if (!isset($jsOptions['addressNotFound'])) {
$hasMainCategory = isset(Yii::$app->i18n->translations['*']) || isset(Yii::$app->i18n->translations['main']);
$jsOptions['addressNotFound'] = $hasMainCategory ? Yii::t('main', 'Address not found') : 'Address not found';
}
$this->view->registerJs(new JsExpression('
$(document).ready(function() {
$(\'#' . $this->wrapperOptions['id'] . '\').selectLocation(' . Json::encode($jsOptions) . ');
});
'));
$mapHtml = Html::tag('div', '', $this->wrapperOptions);
$mapHtml .= Html::activeHiddenInput($this->model, $this->attributeLatitude);
$mapHtml .= Html::activeHiddenInput($this->model, $this->attributeLongitude);
if (is_callable($this->renderWidgetMap)) {
return call_user_func_array($this->renderWidgetMap, [$mapHtml]);
}
return Html::activeInput('text', $this->model, $this->attribute, $this->textOptions) . $mapHtml;
}
示例9: run
/**
* @inheritdoc
*/
public function run()
{
parent::run();
$view = $this->getView();
if (is_array($this->maskOptions)) {
if ($this->hasModel()) {
$this->maskOptions = ArrayHelper::merge($this->maskOptions, ['options' => $this->options, 'model' => $this->model, 'attribute' => $this->attribute]);
} else {
$this->maskOptions = ArrayHelper::merge($this->maskOptions, ['options' => $this->options, 'name' => $this->name, 'value' => $this->value]);
}
$input = MaskedInput::widget($this->maskOptions);
} else {
$input = $this->hasModel() ? Html::activeTextInput($this->model, $this->attribute, $this->options) : Html::textInput($this->name, $this->value, $this->options);
}
$options = Json::encode($this->pluginOptions);
$callback = isset($this->callback) ? ", {$this->callback}" : '';
$script = "moment.locale('{$this->locale}');";
$script .= "\$('#{$this->options['id']}').daterangepicker({$options}{$callback});";
$view->registerJs($script);
echo strtr($this->template, ['{input}' => $input]);
MomentAsset::$locale = $this->locale;
MomentAsset::register($view);
DateRangePickerAsset::register($view);
}
示例10: run
public function run()
{
//prepare data
$view = $this->getView();
//render input for results
if ($this->_renderInput) {
if ($this->hasModel()) {
echo Html::activeHiddenInput($this->model, $this->attribute, $this->options);
} else {
echo Html::hiddenInput($this->name, $this->value, $this->options);
}
}
//render editor container
$containerOptions = $this->containerOptions;
$tag = ArrayHelper::remove($containerOptions, 'tag', 'div');
echo Html::tag($tag, '', $containerOptions);
//prepare client options
$clientOptions = $this->clientOptions;
$clientOptions['schema'] = $this->schema;
ArrayHelper::remove($clientOptions, 'startval');
$clientOptions = Json::encode($clientOptions);
//prepare element IDs
$widgetId = $this->id;
$inputId = $this->inputId;
$containerId = $this->containerOptions['id'];
//register js code
$view->registerJs(<<<JS
var {$widgetId} = new JSONEditor(document.getElementById('{$containerId}'), {$clientOptions});
try {
var initialValue = JSON.parse(document.getElementById('{$inputId}').value);
{$widgetId}.setValue(initialValue);
} catch (e) {
console.log('Could not parse initial value for {$widgetId}');
}
{$widgetId}.on('change', function() {
document.getElementById('{$inputId}').value = JSON.stringify({$widgetId}.getValue());
});
JS
, $view::POS_READY);
parent::run();
}
示例11: run
/**
* @return string
*/
public function run()
{
parent::run();
$this->registerJs();
return $this->hasModel() ? Html::activeDropDownList($this->model, $this->attribute, $this->items, $this->options) : Html::dropDownList($this->name, $this->value, $this->items, $this->options);
}
示例12: run
public function run()
{
parent::run();
$this->renderWidget();
}
示例13: run
/**
* Run the widget
*/
public function run()
{
parent::run();
if ($this->showExport) {
echo $this->renderExportForm();
}
echo Html::endTag('div');
echo Html::endTag('div');
}
示例14: run
/**
* @inheritdoc
*/
public function run()
{
parent::run();
$this->registerAssets();
echo $this->renderInput();
}
示例15: run
public function run()
{
\yii\jui\AutoComplete::widget();
parent::run();
}