本文整理汇总了PHP中DataForm::source方法的典型用法代码示例。如果您正苦于以下问题:PHP DataForm::source方法的具体用法?PHP DataForm::source怎么用?PHP DataForm::source使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataForm
的用法示例。
在下文中一共展示了DataForm::source方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
// load the create form (app/views/teams/create.blade.php)
//return View::make('teams.create');
$form = \DataForm::source(new Product());
$form->add('name', trans('main.name'), 'text')->rule('required|min:2|max:255');
$form->add('description', trans('main.description'), 'textarea')->rule('required|max:255');
$form->add('price', trans('main.price'), 'text')->rule('integer');
$form->add('image', trans('main.image'), 'image')->move('images/products/')->preview(300, 300)->resize(300, 300);
$form->submit(trans('main.save'));
$form->saved(function () use($form) {
$form->message(trans('main.saved'));
$form->link("dashboard/products/create", trans('main.back'));
});
return view('dashboard.create', compact('form'));
}
示例2: getIndex
public function getIndex()
{
$form = \DataForm::source(User::find(Auth::user()->id));
$form->add('name', 'Name', 'text')->rule('required|min:5');
$form->add('email', 'E-mail', 'text')->rule('required|email');
$form->add('theme', 'Theme', 'select')->options(Config::get('rapyd-dashboard::AdminLTE.themes'))->rule('required');
$form->add('avatar', 'Avatar', 'select')->options(array_combine(Config::get('rapyd-dashboard::AdminLTE.avatar'), Config::get('rapyd-dashboard::AdminLTE.avatar')))->rule('required');
$form->submit('Update Profile');
$form->saved(function () use($form) {
\Session::flash('message', array('type' => 'success', 'msg' => 'Profile updated'));
return redirect()->action('\\Skydiver\\RapydDashboard\\Controllers\\ProfileController@getIndex');
});
$form->build();
# GET USER LOGINS
$logins = LogLogin::where('user_id', Auth::user()->id)->orderBy('updated_at', 'desc')->take(5)->get();
return $form->view('rapyd-dashboard::profile.index', compact('form', 'logins'))->with('title', 'Edit profile');
}
示例3: anyStyledform
public function anyStyledform()
{
$form = \DataForm::source(Article::find(1));
$form->add('title', 'Title', 'text')->rule('required|min:5');
$form->add('body', 'Body', 'redactor');
$form->add('categories.name', 'Categories', 'tags');
$form->add('photo', 'Photo', 'image')->move('uploads/demo/')->fit(240, 160)->preview(120, 80);
$form->submit('Save');
$form->saved(function () use($form) {
$form->message("ok record saved");
$form->link("/rapyd-demo/styledform", "back to the form");
});
$form->build();
return view('rapyd::demo.styledform', compact('form'));
}