本文整理汇总了PHP中yii\helpers\Html::activeInput方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::activeInput方法的具体用法?PHP Html::activeInput怎么用?PHP Html::activeInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Html
的用法示例。
在下文中一共展示了Html::activeInput方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderFileContent
public function renderFileContent()
{
$attribute = $this->attribute;
$input = $thumb = '';
$selectedFileOpt = ['class' => 'fm-browse-input'];
if ($this->model->{$attribute}) {
$filesModel = \Yii::$app->getModule('filemanager')->models['files'];
$file = $filesModel::findOne(['file_identifier' => $this->model->{$attribute}]);
}
if (isset($file) && $file) {
$fileType = $file->mime_type;
if ($file->dimension) {
$src = $file->object_url . $file->thumbnail_name;
$fileType = 'image';
} else {
$src = $file->object_url . $file->src_file_name;
}
$gridBox = new \dpodium\filemanager\components\GridBox(['owner' => $this, 'src' => $src, 'fileType' => $fileType, 'toolArray' => [['tagType' => 'i', 'options' => ['class' => 'fa-icon fa fa-times fm-remove', 'title' => Yii::t('filemanager', 'Remove')]]], 'thumbnailSize' => \Yii::$app->getModule('filemanager')->thumbnailSize]);
foreach ($this->fileData as $attribute) {
$value = isset($file->{$attribute}) ? $file->{$attribute} : null;
$input .= Html::input('input', "Filemanager[{$attribute}]", $value);
}
$thumb = $gridBox->renderGridBox();
} else {
$selectedFileOpt['value'] = '';
}
$fileView = Html::tag('div', $thumb, ['class' => 'fm-browse-selected-view']);
$selectedFile = Html::activeInput('input', $this->model, $this->attribute, $selectedFileOpt);
$buttonClass = empty($this->options['class']) ? 'btn btn-primary' : $this->options['class'];
$browseButton = Html::label(Yii::t('filemanager', 'Browse'), Html::getInputId($this->model, $this->attribute), ['class' => 'fm-btn-browse btn-browse ' . $buttonClass, 'data-url' => Url::to(['/filemanager/files/browse']), 'data-backdrop' => 'static', 'data-toggle' => 'modal', 'data-target' => '#fm-modal']);
return $fileView . $browseButton . $selectedFile . $input;
}
示例2: run
/**
* @inheritdoc
*/
public function run()
{
try {
$this->_initAndValidate();
$valueArray = [];
$trees = [];
$valueSingle = "";
$select = "";
$singleInput = "";
if (in_array($this->mode, [self::MOD_COMBO, self::MOD_MULTI])) {
$valueArray = Html::getAttributeValue($this->model, $this->attribute);
$select = Html::activeListBox($this->model, $this->attribute, ['16' => "16"], ['multiple' => true, 'class' => 'sx-controll-element', 'style' => 'display: none;']);
$trees = Tree::find()->where(['id' => $valueArray])->all();
}
if (in_array($this->mode, [self::MOD_COMBO, self::MOD_SINGLE])) {
$singleInput = Html::activeInput("hidden", $this->model, $this->attributeSingle, ['class' => 'sx-single']);
$valueSingle = Html::getAttributeValue($this->model, $this->attributeSingle);
}
$src = UrlHelper::construct('/cms/admin-tree')->set('mode', $this->mode)->set('s', $valueArray)->setSystemParam(Module::SYSTEM_QUERY_EMPTY_LAYOUT, 'true')->setSystemParam(Module::SYSTEM_QUERY_NO_ACTIONS_MODEL, 'true')->enableAdmin()->toString();
$id = "sx-id-" . md5(serialize([$this->clientOptions, $this->mode, $this->attributeMulti, $this->attributeSingle]));
$selected = [];
foreach ($trees as $tree) {
$selected[] = $tree->id;
}
return $this->render('widget', ['widget' => $this, 'id' => $id, 'select' => $select, 'src' => $src, 'valueSingle' => $valueSingle, 'singleInput' => $singleInput, 'clientOptions' => Json::encode(['src' => $src, 'name' => $id, 'id' => $id, 'selected' => $selected, 'valueSingle' => $valueSingle])]);
//$this->registerClientScript();
} catch (Exception $e) {
echo $e->getMessage();
}
}
示例3: run
/**
* @inheritdoc
*/
public function run()
{
$jsOptions = ['clientOptions' => $this->clientOptions];
$this->options['id'] = 'input-id';
if ($this->hasModel()) {
echo Html::activeInput('file', $this->model, $this->attribute, $this->options);
echo Html::img('#', ['id' => 'cropper-box']);
echo Html::button('Crop', ['id' => 'cropImage']);
$input_name = Html::getInputName($this->model, $this->attribute);
$input_id = Html::getInputId($this->model, $this->attribute);
echo Html::hiddenInput($input_name . '[file]', '', ['id' => $input_id . '_image']);
$jsOptions['model'] = $this->model;
$jsOptions['attribute'] = $this->attribute;
} else {
echo Html::fileInput($this->name, $this->value, $this->options);
echo Html::img('#', ['id' => 'cropper-box']);
echo Html::button('Crop', ['id' => 'cropImage']);
}
if ($this->uploadUrl) {
$this->uploadUrl = \Yii::getAlias($this->uploadUrl);
}
$jsOptions['uploadUrl'] = $this->uploadUrl;
$jsOptions['uploadCroppedUrl'] = $this->uploadCroppedUrl;
$jsOptions['changeUrl'] = $this->changeUrl;
$jsOptions['name'] = $this->name;
$jsOptions['aspectRatio'] = $this->aspectRatio;
$this->registerPlugin($jsOptions);
}
示例4: run
public function run()
{
$this->registerClientScript();
Html::addCssClass($this->wrapperOptions, 'input-touchspin');
echo Html::beginTag('div', $this->wrapperOptions);
if ($this->hasModel()) {
if ($this->default !== false) {
$value = $this->model->{$this->attribute};
if (!is_numeric($value) || $value < $this->min || $value > $this->max) {
$this->model->{$this->attribute} = $this->default;
}
}
echo Html::activeInput($this->type, $this->model, $this->attribute, $this->options);
} else {
if ($this->default !== false) {
if (!is_numeric($this->value) || $this->value < $this->min || $this->value > $this->max) {
$this->value = $this->default;
}
}
echo Html::input($this->type, $this->name, $this->value, $this->options);
}
echo Html::tag('div', null, ['class' => 'caret step-up']);
echo Html::tag('div', null, ['class' => 'caret step-down']);
echo Html::endTag('div');
}
示例5: run
/**
* @return string
*/
public function run()
{
$options = ArrayHelper::merge($this->defaultOptions, $this->options);
if ($this->hasModel()) {
return Html::activeInput($this->htmlTagType, $this->model, $this->attribute, $options);
}
return Html::input($this->htmlTagType, $this->name, $this->value, $options);
}
示例6: renderTable
public function renderTable()
{
$second_day = 24 * 60 * 60;
$weekday = (int) date('N', time());
$monday = time() - ($weekday - 1) * $second_day;
$data = '';
if ($this->model && $this->attribute) {
$options = isset($this->options['inputOptions']) ? $this->options['inputOptions'] : [];
$data = Html::activeInput('hidden', $this->model, $this->attribute, $options);
}
for ($i = 0; $i < 7; $i++) {
$weekday = Yii::$app->getFormatter()->asDate($monday + $i * $second_day, 'php:D');
$data .= Html::beginTag('tr', ['data' => ['day' => $i, 'title' => $weekday]]);
$data .= Html::tag('td', $weekday, ['class' => 'weekday']);
$data .= $this->renderTime($i, '-');
$data .= Html::endTag('tr');
}
$data .= Html::beginTag('tr');
$data .= Html::tag('td', '', ['class' => 'weekday']);
for ($i = 0; $i < 24; $i++) {
$data .= Html::tag('td', ($i <= 9 ? ' ' . $i : $i) . ':00 ' . ($i + 1 <= 9 ? ' ' . ($i + 1) : $i + 1) . ':00', ['class' => 'time']);
}
$data .= Html::endTag('tr');
$return = Html::tag('div', '', ['class' => 'clearfix']);
$return .= $this->renderButtons();
$return .= Html::tag('div', Html::tag('table', $data, ['id' => 'schedule-week-time']), ['class' => 'col-sm-10']);
unset($data);
return $return;
}
示例7: run
public function run()
{
if ($this->hasModel()) {
echo Html::activeInput('text', $this->model, $this->attribute, $this->options);
} else {
echo Html::input('text', $this->name, $this->value, $this->options);
}
}
示例8: run
/**
* @inheritdoc
*/
public function run()
{
$this->registerClientScript();
if ($this->hasModel()) {
echo Html::activeHiddenInput($this->model, $this->attribute, ['id' => null]) . Html::activeInput('file', $this->model, $this->attribute, $this->options);
} else {
echo Html::hiddenInput($this->name, $this->value, ['id' => null]) . Html::input('file', $this->name, $this->value, $this->options);
}
}
示例9: run
public function run()
{
$view = $this->getView();
FileUploadAsset::register($view);
$this->createUploaderOptions();
$this->options['class'] = 'required';
echo Html::hiddenInput(Html::getInputName($this->model, $this->attribute), '', ['id' => 'dwz-file-uploader']);
echo Html::activeInput('file', $this->model, $this->attribute, $this->options);
}
示例10: run
/**
* @inheritdoc
*/
public function run()
{
$this->registerClientScript();
if ($this->hasModel()) {
echo Html::activeInput('text', $this->model, $this->attribute, $this->options);
} else {
echo Html::input('text', $this->name, $this->value, $this->options);
}
}
示例11: run
/**
* @inheritdoc
*/
public function run()
{
if ($this->hasModel()) {
$this->id = Html::getInputId($this->model, $this->attribute);
$this->registerJs('#' . $this->htmlOptions['id'], $this->options, $this->callback);
return Html::activeInput($this->type, $this->model, $this->attribute, $this->htmlOptions + ['class' => 'form-control']);
} else {
$this->registerJs('#' . $this->htmlOptions['id'], $this->options, $this->callback);
return Html::input($this->type, $this->name, $this->value, $this->htmlOptions);
}
}
示例12: registerPlugin
protected function registerPlugin()
{
if ($this->selector) {
$this->registerJs($this->selector, $this->options, $this->callback);
} else {
$id = $this->htmlOptions['id'];
echo Html::activeInput('text', $this->model, $this->attribute, $this->htmlOptions);
// echo Html::tag('input', '', $this->htmlOptions);
$this->registerJs("#{$id}", $this->options, $this->callback);
}
}
示例13: registerPlugin
protected function registerPlugin()
{
if ($this->selector) {
$this->registerJs($this->selector, $this->options, $this->callback);
} else {
$id = $this->options['id'];
$input = $this->hasModel() ? Html::activeInput('text', $this->model, $this->attribute, $this->options) : Html::textInput($this->name, $this->value, $this->options);
echo $input;
$this->registerJs("#{$id}", $this->options, $this->callback);
}
}
示例14: run
public function run()
{
$view = $this->getView();
$id = $this->options['id'];
//Register DtGridViewAsset
DatepickerAsset::register($view);
$content = Html::activeInput($this->type, $this->model, $this->attribute, $this->options);
$clientOptions = Json::encode($this->clientOptions);
$view->registerJs("jQuery('#{$id}').datepicker({$clientOptions});");
return $content;
}
示例15: run
public function run()
{
//var_dump($this->attribute);exit();
$view = $this->getView();
$id = $this->options['id'];
//Register DtGridViewAsset
InputmaskAsset::register($view);
$content = Html::activeInput($this->type, $this->model, $this->attribute, $this->options);
$clientOptions = Json::encode($this->clientOptions);
$alias = Json::encode($this->alias);
$view->registerJs("jQuery('#{$id}').inputmask({$alias},{$clientOptions});");
return $content;
}