本文整理汇总了PHP中yii\helpers\Html::activeHiddenInput方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::activeHiddenInput方法的具体用法?PHP Html::activeHiddenInput怎么用?PHP Html::activeHiddenInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Html
的用法示例。
在下文中一共展示了Html::activeHiddenInput方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderSavedValueInput
public function renderSavedValueInput()
{
if ($this->hasModel()) {
$value = Html::getAttributeValue($this->model, $this->attribute);
} else {
$value = $this->value;
}
if ($value !== null && $value !== '') {
// format value according to saveDateFormat
try {
$value = Yii::$app->formatter->asDate($value, $this->saveDateFormat);
} catch (InvalidParamException $e) {
// ignore exception and keep original value if it is not a valid date
}
}
$this->options['savedValueInputID'] = $this->options['id'] . '-saved-value';
$options = $this->options;
$options['id'] = $options['savedValueInputID'];
$options['value'] = $value;
// render hidden input
if ($this->hasModel()) {
$contents = Html::activeHiddenInput($this->model, $this->attribute, $options);
} else {
$contents = Html::hiddenInput($this->name, $value, $options);
}
return $contents;
}
示例2: init
public function init()
{
parent::init();
\Yii::setAlias('@webuploader', __DIR__);
if (empty($this->driver)) {
$this->driver = isset(\Yii::$app->params['webuploader_driver']) ? \Yii::$app->params['webuploader_driver'] : 'local';
}
if ($this->driver == 'local') {
// 初始化@static别名,默认@web/static,最好根据自己的需求提前设置好@static别名
$static = \Yii::getAlias('@static', false);
$staticroot = \Yii::getAlias('@staticroot', false);
if (!$static || !$staticroot) {
\Yii::setAlias('@static', '@web/static');
\Yii::setAlias('@staticroot', '@webroot/static');
}
}
$this->server = $this->server ?: Url::to(['/site/webupload', 'driver' => $this->driver]);
$this->options['boxId'] = isset($this->options['boxId']) ? $this->options['boxId'] : 'picker';
$this->options['previewWidth'] = isset($this->options['previewWidth']) ? $this->options['previewWidth'] : '250';
$this->options['previewHeight'] = isset($this->options['previewHeight']) ? $this->options['previewHeight'] : '150';
if ($this->hasModel()) {
$this->hiddenInput = Html::activeHiddenInput($this->model, $this->attribute);
} else {
$this->hiddenInput = Html::hiddenInput($this->name, $this->value);
}
}
示例3: render
public function render($content = null)
{
$this->inputOptions['name'] = '';
if ($content === null) {
if (!isset($this->parts['{input}'])) {
// $this->inputOptions['data-bind'] = sprintf('value: %s', $this->attribute);
$this->parts['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->inputOptions);
}
if (!isset($this->parts['{hidden}'])) {
$this->parts['{hidden}'] = Html::activeHiddenInput($this->model, $this->attribute, $this->hiddenOptions);
}
if (!isset($this->parts['{label}'])) {
$this->parts['{label}'] = Html::activeLabel($this->model, $this->attribute, $this->labelOptions);
}
if (!isset($this->parts['{error}'])) {
$this->parts['{error}'] = Html::error($this->model, $this->attribute, $this->errorOptions);
}
if (!isset($this->parts['{hint}'])) {
$this->parts['{hint}'] = '';
}
$content = strtr($this->template, $this->parts);
} elseif (!is_string($content)) {
$content = call_user_func($content, $this);
}
return empty($content) ? '' : ($this->wrapper ? $this->begin() . "\n" . $content . "\n" . $this->end() : $content);
}
示例4: defaultColumns
public static function defaultColumns()
{
return ['fqdn' => ['attribute' => 'fqdn', 'value' => function ($model) {
return $model->fqdn;
}], 'type' => ['value' => function ($model) {
return strtoupper($model->type);
}], 'value' => ['value' => function ($model) {
return $model->getValueText();
}], 'zone' => ['class' => MainColumn::className(), 'label' => Yii::t('hipanel:dns', 'Zone'), 'attribute' => 'name'], 'actions' => ['class' => ActionColumn::className(), 'template' => '{update} {delete}', 'visibleButtonsCount' => 2, 'options' => ['style' => 'width: 15%'], 'buttons' => ['update' => function ($url, $model, $key) {
if ($model->is_system) {
return Html::tag('div', Html::a('<i class="fa fa-pencil"></i> ' . Yii::t('hipanel', 'Update'), null, ['class' => 'btn btn-default btn-xs disabled']), ['data-placement' => 'top', 'data-toggle' => 'tooltip', 'title' => Yii::t('hipanel:dns', 'This record was created by hosting panel automatically and cannot be updated'), 'style' => 'display: inline-block; cursor: not-allowed;']);
}
$data = Html::a('<i class="fa fa-pencil"></i> ' . Yii::t('hipanel', 'Update'), null, ['class' => 'btn btn-default btn-xs edit-dns-toggle', 'data' => ['record_id' => $model->id, 'hdomain_id' => $model->hdomain_id, 'load-url' => Url::to(['@dns/record/update', 'hdomain_id' => $model->hdomain_id, 'id' => $model->id])]]);
$progress = Json::htmlEncode("<tr><td colspan='5'>" . Progress::widget(['id' => 'progress-bar', 'percent' => 100, 'barOptions' => ['class' => 'active progress-bar-striped', 'style' => 'width: 100%']]) . '</td></tr>');
Yii::$app->view->registerJs("\n \$('.edit-dns-toggle').click(function () {\n var record_id = \$(this).data('id');\n var hdomain_id = \$(this).data('hdomain_id');\n\n var currentRow = \$(this).closest('tr');\n var newRow = \$({$progress});\n\n \$(newRow).data({'record_id': record_id, hdomain_id: hdomain_id});\n \$('tr').filter(function () { return \$(this).data('id') == record_id; }).find('.btn-cancel').click();\n \$(newRow).insertAfter(currentRow);\n\n jQuery.ajax({\n url: \$(this).data('load-url'),\n type: 'GET',\n timeout: 0,\n error: function() {\n\n },\n success: function(data) {\n newRow.find('td').html(data);\n newRow.find('.btn-cancel').on('click', function (event) {\n event.preventDefault();\n newRow.remove();\n });\n }\n });\n\n });\n ");
return $data;
}, 'delete' => function ($url, $model, $key) {
if ($model->type === 'ns' && $model->is_system) {
return Html::tag('div', Html::a('<i class="fa text-danger fa-trash-o"></i> ' . Yii::t('hipanel', 'Delete'), null, ['class' => 'btn btn-default btn-xs disabled']), ['data-placement' => 'top', 'data-toggle' => 'tooltip', 'title' => Yii::t('hipanel:dns', 'This record is important for the domain zone viability and can not be deleted'), 'style' => 'display: inline-block; cursor: not-allowed;']);
}
return ModalButton::widget(['model' => $model, 'scenario' => 'delete', 'submit' => ModalButton::SUBMIT_PJAX, 'form' => ['action' => Url::to('@dns/record/delete')], 'button' => ['class' => 'btn btn-default btn-xs', 'label' => '<i class="fa text-danger fa-trash-o"></i> ' . Yii::t('hipanel', 'Delete')], 'modal' => ['header' => Html::tag('h4', Yii::t('hipanel:dns', 'Confirm DNS record deleting')), 'headerOptions' => ['class' => 'label-danger'], 'footer' => ['label' => Yii::t('hipanel:dns', 'Delete record'), 'data-loading-text' => Yii::t('hipanel:dns', 'Deleting record...'), 'class' => 'btn btn-danger']], 'body' => function ($model) {
echo Html::activeHiddenInput($model, 'hdomain_id');
echo Yii::t('hipanel:dns', 'Are you sure, that you want to delete record {name}?', ['name' => $model->fqdn]);
}]);
}]]];
}
示例5: renderRow
/**
*
* @param biz\models\GlDetail $model
* @param integer $index
* @return string
*/
function renderRow($model, $index)
{
ob_start();
ob_implicit_flush(false);
?>
<tr>
<?php
echo Html::activeHiddenInput($model, "[{$index}]id_gl_detail");
?>
<td class="serial"><?php
echo $index;
?>
</td>
<td><?php
echo Html::activeTextInput($model, "[{$index}]id_coa");
?>
</td>
<td><?php
echo Html::activeTextInput($model, "[{$index}]debit");
?>
</td>
<td><?php
echo Html::activeTextInput($model, "[{$index}]kredit");
?>
</td>
<td class="action"><a class="fa fa-minus-square-o" href="#"></a></td>
</tr>
<?php
return trim(preg_replace('/>\\s+</', '><', ob_get_clean()));
}
示例6: run
/**
* Renders the widget.
*/
public function run()
{
$contents = [];
if ($this->inline) {
if ($this->hasModel()) {
$contents[] = Html::activeHiddenInput($this->model, $this->attribute, $this->options);
} else {
$contents[] = Html::hiddenInput($this->name, $this->value, $this->options);
}
$contents[] = Html::tag('div', '', $this->containerOptions);
} else {
if ($this->hasModel()) {
$contents[] = Html::activeTextInput($this->model, $this->attribute, $this->options);
} else {
$contents[] = Html::textInput($this->name, $this->value, $this->options);
}
}
echo implode("\n", $contents);
if ($this->language) {
DatePickerAsset::$extraJs[] = 'plugins/bootstrap-datepicker-extended/js/locales/bootstrap-datepicker.' . $this->language . '.js';
$this->clientOptions['language'] = $this->language;
}
DatePickerAsset::register($this->view);
$this->registerPlugin('datepicker');
if ($this->inline) {
$this->view->registerJs("\n !(function(\$){\n var el = \$('#{$this->options['id']}'),\n val = el.val(),\n container = \$('#{$this->containerOptions['id']}');\n container.on('changeDate', function(e){\n el.val(e.format());\n });\n if(val) {\n container.datepicker('update', new Date(Date.parse(val)));\n }\n })(jQuery);\n ", View::POS_READY);
}
}
示例7: run
public function run()
{
if ($this->hasModel()) {
$replace['{input}'] = Html::activeHiddenInput($this->model, $this->attribute, $this->options);
$attributeId = Html::getInputId($this->model, $this->attribute);
$id = Html::getInputId($this->model, 'hydra_' . $this->attribute);
$name = Html::getInputName($this->model, 'hydra_' . $this->attribute);
$this->value = $this->model[$this->attribute];
} else {
$replace['{input}'] = Html::hiddenInput($this->name, $this->value, $this->options);
$name = $id = 'hydra_' . $this->name;
$attributeId = $this->name;
}
$fileInputName = empty($this->fileInputName) ? $name : $this->fileInputName;
$replace['{preview}'] = 'Файл еще не загружен';
if (!empty($this->value)) {
$replace['{preview}'] = $this->value;
$extension = Yii::$app->hydra->getExtension($this->value);
if (Yii::$app->hydra->isImage($extension)) {
$replace['{preview}'] = Html::img(Yii::$app->hydra->getCacheUrl($this->value, $this->resolution), ['id' => $id . '_image']);
}
$replace['{reset-button}'] = Html::tag($this->resetButton['tag'], $this->resetButton['label'], ArrayHelper::merge(['onClick' => '$("#' . $attributeId . '").val("");$("#' . $id . '_image' . '").remove();$(this).remove();'], $this->resetButton['options']));
}
$replace['{input}'] .= Html::fileInput($fileInputName, null, ArrayHelper::merge(['id' => $id], $this->fileInput['options']));
return strtr($this->template, $replace);
}
示例8: init
public function init()
{
$id = $this->getId();
$options = Json::htmlEncode(ArrayHelper::merge($this->options, ['uploader' => ['backendUrl' => Url::to($this->url)], 'files' => $this->getFiles(), 'multiple' => $this->multiple]));
$this->getView()->registerJs("jQuery('#{$id}').fileInput({$options})");
echo Html::activeHiddenInput($this->model, $this->attribute, ['id' => $id]);
}
示例9: init
public function init()
{
$value = $this->model->{$this->attribute};
if (is_int($value) || is_float($value) || is_string($value) && strlen($value)) {
$this->inputOptions['value'] = Text::date($this->dateFormat . $this->separator . $this->timeFormat, $value);
$this->hiddenInputOptions['value'] = Text::date($this->altDateFormat . $this->altSeparator . $this->altTimeFormat, $value);
}
if (!$this->readOnly) {
$pluginOptions = array_merge(['numberOfMonths' => 3, 'showButtonPanel' => true, 'altFieldTimeOnly' => false], $this->pluginOptions, ['dateFormat' => Text::juiDateFormat($this->dateFormat), 'altFormat' => Text::juiDateFormat($this->altDateFormat), 'separator' => $this->separator, 'altSeparator' => $this->altSeparator, 'timeFormat' => Text::juiTimeFormat($this->timeFormat), 'altTimeFormat' => Text::juiTimeFormat($this->altTimeFormat)]);
$inputId = Html::getInputId($this->model, $this->attribute);
$pluginOptions['altField'] = '#' . $inputId . '-alt';
$js = 'jQuery(\'#' . $inputId . '\').datetimepicker(' . Json::encode($pluginOptions) . ');';
$this->inputOptions['name'] = false;
$this->hiddenInputOptions['id'] = $inputId . '-alt';
$this->template .= "\n{hiddenInput}";
$this->parts['{hiddenInput}'] = Html::activeHiddenInput($this->model, $this->attribute, $this->hiddenInputOptions);
if (Yii::$app->getRequest()->getIsAjax()) {
$this->template .= "\n{script}";
$this->parts['{script}'] = Html::script($js);
} else {
$view = $this->form->getView();
TimePickerAsset::register($view);
$view->registerJs($js);
}
}
parent::init();
}
示例10: hiddenInput
public function hiddenInput($options = [])
{
$options = array_merge($this->inputOptions, $options);
$this->adjustLabelFor($options);
$this->parts['{label}'] = false;
$this->parts['{input}'] = Html::activeHiddenInput($this->model, $this->attribute, $options);
return $this;
}
示例11: renderInput
private function renderInput()
{
if ($this->hasModel()) {
return Html::activeHiddenInput($this->model, $this->attribute, $this->options);
} else {
return Html::hiddenInput($this->name, $this->value, $this->options);
}
}
示例12: run
/**
* @inheritdoc
*/
public function run()
{
if ($this->hasModel()) {
return Html::activeHiddenInput($this->model, $this->attribute, $this->options);
} else {
return Html::hiddenInput($this->name, '', $this->options);
}
}
示例13: renderWidget
public function renderWidget()
{
if ($this->hasModel()) {
$result = Html::activeHiddenInput($this->model, $this->attribute);
} else {
$result = Html::hiddenInput($this->name, $this->value);
}
}
示例14: run
/**
* @inheritdoc
*/
public function run()
{
$this->registerAssets();
if ($this->name === null) {
return Html::activeHiddenInput($this->model, $this->attribute, $this->options);
}
return Html::hiddenInput($this->name, $this->value, $this->options);
}
示例15: renderInput
/**
* Renders a text input for widget display along with an internal
* hidden input to validate and save the raw number (float) data.
*/
protected function renderInput()
{
$name = $this->_displayOptions['id'];
Html::addCssClass($this->_displayOptions, 'form-control');
$input = Html::textInput($name, $this->value, $this->_displayOptions);
$input .= $this->hasModel() ? Html::activeHiddenInput($this->model, $this->attribute, $this->options) : Html::hiddenInput($this->name, $this->value, $this->options);
echo $input;
}