PHP code example of ambitionphp / laravel-livewire-forms
1. Go to this page and download the library: Download ambitionphp/laravel-livewire-forms library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ambitionphp / laravel-livewire-forms example snippets
public function fields()
{
return [
Input::make('name', 'Name'),
Input::make('email', 'Email')->type('email'),
Input::make('password', 'Password')->type('password'),
];
}
public function buttons()
{
return [
Button::make('Create User')->click('createUser'),
Button::make('Cancel', 'secondary')->url('/'),
];
}
public function rules()
{
return [
'name' => ['5', 'unique:users'],
'password' => ['
public function createUser()
{
$this->validate();
User::create([
'name' => $this->data('name'),
'email' => $this->data('email'),
'password' => Hash::make($this->data('password')),
]);
return redirect('/');
}
class Login extends FormComponent
{
public $title = 'Login';
public $layout = 'layouts.card';
public function route()
{
return Route::get('/login', static::class)
->name('login')
->middleware('guest');
}
class UpdateUserForm extends FormComponent
{
public $title = 'Update User';
public function route()
{
return Route::get('/users/update/{user}', static::class)
->name('users.update')
->middleware('auth');
}
public function mount(User $user)
{
$this->data = $user->toArray();
}
public function createUser()
{
User::create([
'name' => $this->data('name'),
'email' => $this->data('email'),
'likes_turtles' => $this->data('answers.likes_turtles'),
]);
}
Input::make('name', 'Name'), // defaults to defer
Input::make('name', 'Name')->instant(), // bind on keyup
Input::make('name', 'Name')->defer(), // bind on action
Input::make('name', 'Name')->lazy(), // bind on change
Input::make('name', 'Name')->debounce(500), // bind after 500ms delay
Input::make('name', 'Name'), // defaults to normal sizing
Input::make('name', 'Name')->small(), // small sizing
Input::make('name', 'Name')->large(), // large sizing