本文整理汇总了PHP中FormItem::text方法的典型用法代码示例。如果您正苦于以下问题:PHP FormItem::text方法的具体用法?PHP FormItem::text怎么用?PHP FormItem::text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormItem
的用法示例。
在下文中一共展示了FormItem::text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
<?php
Admin::model('App\\Page')->title('Pages')->display(function () {
$display = AdminDisplay::tree();
$display->value('title');
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::text('title', 'Title'), FormItem::ckeditor('text', 'Text')]);
return $form;
});
示例2: date
<?php
/*
* This is a simple example of the main features.
* For full list see documentation.
*/
// Create admin model from User class with title and url alias
Admin::model(\App\User::class)->title('Users')->denyCreating(function () {
// Deny creating on thursday
return date('w') == 4;
})->denyEditingAndDeleting(function ($instance) {
// deny editing and deleting rows when this is true
return $instance->id <= 2 || $instance->email == 'admin';
})->columns(function () {
// Describing columns for table view
Column::string('name', 'Name');
Column::string('email', 'Email');
})->form(function () {
// Describing elements in create and editing forms
FormItem::text('name', 'Name');
FormItem::text('email', 'Email');
});
示例3:
<?php
Admin::model('App\\Marker')->title('Маркеры')->display(function () {
$display = AdminDisplay::datatables();
$display->with('markerGroups');
$display->filters([]);
$display->columns([Column::string('name')->label('Имя'), Column::lists('markerGroups.name')->label('Входит в группы'), Column::image('ico')->label('Иконка')]);
return $display;
})->create(function () {
$form = AdminForm::form();
$form->items([FormItem::columns()->columns([[FormItem::text('name', 'Имя'), FormItem::image('ico', 'Иконка'), FormItem::checkbox('showadd', 'Показывать в форме добавления рецепта')->defaultValue(0), FormItem::text('sortorder', 'Порядок сортировки')], [FormItem::text('metakey', 'Meta Keywords'), FormItem::text('metadesk', 'Meta Description'), FormItem::text('slug', 'Slug (если пустое, генерируется реалтайм из имени)'), FormItem::text('title', 'Title')]])]);
return $form;
})->edit(function () {
$form = AdminForm::form();
$form->items([FormItem::columns()->columns([[FormItem::text('name', 'Имя'), FormItem::image('ico', 'Иконка'), FormItem::checkbox('showadd', 'Показывать в форме добавления рецепта'), FormItem::text('sortorder', 'Порядок сортировки')], [FormItem::text('metakey', 'Meta Keywords'), FormItem::text('metadesk', 'Meta Description'), FormItem::text('slug', 'Slug (если пустое, генерируется реалтайм из имени)'), FormItem::text('title', 'Title')]])]);
return $form;
});
示例4:
<?php
Admin::model(\App\Models\News::class)->title('News')->with()->filters(function () {
})->columns(function () {
Column::string('title', 'Title');
Column::date('date', 'Date')->format('medium', 'none');
Column::string('published', 'Published');
// Column::string('text', 'Text');
Column::image('photo', 'Photo')->sortable(false);
})->form(function () {
FormItem::text('title', 'Title')->required();
FormItem::date('date', 'Date')->required();
FormItem::checkbox('published', 'Published')->required();
FormItem::image('photo', 'Photo');
FormItem::ckeditor('text', 'Text')->required();
});
示例5:
<?php
Admin::model('App\\News4')->title('News')->alias('news4')->display(function () {
$display = AdminDisplay::table();
$display->filters([Filter::scope('last')->title('Latest News'), Filter::field('published')->title(function ($value) {
return $value ? 'Published' : 'Not Published';
}), Filter::custom('limit')->title(function ($value) {
return 'Custom Filter: ' . $value;
})->callback(function ($query, $value) {
$query->limit($value);
})]);
$display->columns([Column::string('title')->label('Title'), Column::datetime('date')->label('Date')->format('d.m.Y'), Column::custom()->label('Published')->callback(function ($instance) {
return $instance->published ? '✓' : '-';
})]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::text('title', 'Title')->required(), FormItem::date('date', 'Date')->required()->format('d.m.Y'), FormItem::checkbox('published', 'Published'), FormItem::ckeditor('text', 'Text')]);
return $form;
});
示例6:
<?php
Admin::model(App\Category::class)->title('Category')->with()->filters(function () {
})->columns(function () {
Column::string('name', 'Name');
Column::string('description', 'Description');
Column::string('classification.name', 'Classification');
})->form(function () {
FormItem::text('name', 'Name');
FormItem::text('description', 'Description');
FormItem::select('classification_id', 'Classification')->list(\App\Classification::class);
});
示例7: use
<?php
/** @var \SleepingOwl\Admin\Model\ModelConfiguration $model */
$model = Admin::model(\App\HistoryEvent::class);
$model->title('История – события');
$model->display(function () {
$display = AdminDisplay::datatables();
$display->with('date');
$display->columns([Column::checkbox(), Column::string('date.title')->label('Дата'), Column::custom()->label('Заголовок')->callback(function ($instance) {
$res = $instance->title;
if ($instance->more) {
$res .= '<br><div class="label label-primary">Кнопка – подробней</div>';
}
return $res;
}), Column::datetime('date_event')->format('d.m.Y')->label('Точная дата события'), Column::datetime('created_at')->label('Создан')->format('d.m.Y в H:i')]);
$display->apply(function (\Illuminate\Database\Eloquent\Builder $query) {
$query->withTrashed();
});
return $display;
})->createAndEdit(function ($id) use($model) {
$model->title($id ? 'Редактировать событие' : 'Создать событие');
$form = AdminForm::form();
$form->items([FormItem::text('title', 'Заголовок'), FormItem::image('image', 'Картинка'), FormItem::select('history_date_id', 'Дата')->model(\App\HistoryDate::class)->display('title')->required(), FormItem::ckeditor('description', 'Описание')->required(), FormItem::date('date_event', 'Точная дата события'), FormItem::checkbox('more', 'Показать кнопку – подробней')]);
return $form;
});
示例8:
<?php
/*
* This is a simple example of the main features.
* For full list see documentation.
*/
Admin::model('App\\Models\\Country')->title('Countries')->alias('country')->display(function () {
$display = AdminDisplay::datatablesAsync();
$display->order([[0, 'asc']]);
$display->columns([Column::string('code')->label('Code'), Column::string('name')->label('Name'), Column::string('local_name')->label('Local name'), Column::datetime('created_at')->format('d-m-Y h:i:s')->label('Created'), Column::datetime('updated_at')->format('d-m-Y h:i:s')->label('Updated')]);
$display->columnFilters([ColumnFilter::text()->placeholder('Code'), ColumnFilter::text()->placeholder('Name'), ColumnFilter::text()->placeholder('Local name'), ColumnFilter::range()->from(ColumnFilter::date()->format('d.m.Y')->placeholder('From Date'))->to(ColumnFilter::date()->format('d.m.Y')->placeholder('To Date')), ColumnFilter::range()->from(ColumnFilter::date()->format('d.m.Y')->placeholder('From Date'))->to(ColumnFilter::date()->format('d.m.Y')->placeholder('To Date'))]);
return $display;
})->create(function () {
$form = AdminForm::form();
$form->items([FormItem::text('code', 'Code')->required(), FormItem::text('name', 'Name')->required(), FormItem::text('local_name', 'Local Name')->required()]);
return $form;
})->edit(null)->delete(null);
示例9:
<?php
// Pages
Admin::model('\\App\\Page')->title('Pages')->as('pages')->denyCreating(function () {
// Deny creating on thursday
return false;
})->denyEditingAndDeleting(function ($instance) {
// deny editing and deleting rows when this is true
return false;
})->columns(function () {
// Describing columns for table view
Column::string('title', 'Title');
Column::date('created_at', 'Created');
})->form(function () {
// Describing elements in create and editing forms
FormItem::text('title', 'Title');
FormItem::ckeditor('content', 'Content');
});
示例10:
<?php
Admin::model('App\\Models\\CmsOption')->title('Общие настройки')->display(function () {
$display = AdminDisplay::datatables();
$display->with();
$display->filters([]);
$display->columns([Column::string('name')->label('Name'), Column::string('value')->label('Value'), Column::string('id')->label('Id')]);
return $display;
})->create(function () {
$form = AdminForm::form();
$form->items([FormItem::text('name', 'Название опции (Используется в коде)'), FormItem::text('value', 'Значение')]);
return $form;
})->edit(function () {
$form = AdminForm::form();
$form->items([FormItem::text('name', 'Name'), FormItem::text('value', 'Value')]);
return $form;
})->delete(function ($id) {
if (in_array($id, [1, 2, 3, 4])) {
return null;
} else {
return 1;
}
});
示例11:
<?php
Admin::model('Cartalyst\\Sentinel\\Users\\EloquentUser')->title('Юзеры')->display(function () {
$display = AdminDisplay::datatables();
$display->with();
$display->filters([]);
$display->columns([Column::string('id')->label('Id'), Column::string('email')->label('Email'), Column::string('first_name')->label('Имя')]);
return $display;
})->create(function () {
$form = AdminForm::form();
$form->items([FormItem::columns()->columns([[FormItem::text('email', 'Email'), FormItem::password('password', 'Пароль'), FormItem::password('password_confirm', 'Подтверждение пароля')], [FormItem::text('first_name', 'Имя'), FormItem::text('last_name', 'Фамилия'), FormItem::view('admin.user_create')]])]);
return $form;
})->edit(function () {
$form = AdminForm::form();
$form->items([FormItem::columns()->columns([[FormItem::text('email', 'Email'), FormItem::password('password', 'Пароль'), FormItem::password('password_confirm', 'Подтверждение пароля')], [FormItem::text('first_name', 'Имя'), FormItem::text('last_name', 'Фамилия'), FormItem::view('admin.user_update')]])]);
return $form;
});
示例12:
<?php
Admin::model(\App\Model\Category::class)->title('Категории Блога')->display(function () {
$display = AdminDisplay::datatables();
$display->with('pages');
$display->filters([]);
$display->columns([Column::string('title')->label('Название'), Column::count('pages.id')->label('Количество статей'), Column::action('show')->label('Label')->callback(function ($query) {
return $query->active ? '✓' : '-';
})]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::tabbed();
$form->items(['Main' => [FormItem::hidden('user_id')->defaultValue(AdminAuth::user()->id), FormItem::text('title', 'Заголовок'), FormItem::text('slug', 'Slug - Заполняется автоматически'), FormItem::ckeditor('content', 'Content'), FormItem::textarea('descriptor', 'Краткое описание')]]);
return $form;
});
示例13:
<?php
Admin::model(App\Role::class)->title('Роли')->display(function () {
$display = AdminDisplay::datatables();
$display->with('permits');
$display->filters([]);
$display->columns([Column::string('id')->label('Id'), Column::string('name')->label('Name'), Column::string('slug')->label('Slug')]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::text('slug', 'Slug'), FormItem::text('name', 'Name'), FormItem::multiselect('permits', 'Права доступа')->model('App\\Permit')->display('name')]);
return $form;
});
示例14:
<?php
Admin::model('App\\MarkerGroup')->title('Группы маркеров')->display(function () {
$display = AdminDisplay::datatables();
$display->with('markers');
$display->filters([]);
$display->columns([Column::string('name')->label('Имя'), Column::string('id')->label('ID'), Column::lists('markers.name')->label('Маркеры')]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::text('name', 'Имя')->required(), FormItem::checkbox('showadd', 'Показывать в форме добавления рецепта'), FormItem::image('ico', 'Иконка'), FormItem::text('metakey', 'Meta Keywords'), FormItem::text('metadesk', 'Meta Description'), FormItem::multiselect('markers', 'Маркеры')->model('App\\Marker')->display('name')]);
return $form;
})->delete(function ($id) {
if (in_array($id, [1, 2, 3])) {
return null;
} else {
return 1;
}
});
示例15:
<?php
/*
* This is a simple example of the main features.
* For full list see documentation.
*/
Admin::model('App\\User')->title('Users')->display(function () {
$display = AdminDisplay::table();
$display->columns([Column::string('name')->label('Name'), Column::string('email')->label('Email')]);
return $display;
})->alias('users')->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::text('name', 'Name')->required(), FormItem::text('email', 'Email')->required()->unique()]);
return $form;
});