PHP code example of codions / laravel-livewire-forms
1. Go to this page and download the library: Download codions/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/ */
codions / 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 FormSliderComponent
{
public $title = 'Login';
public $layout = 'layouts.card';
public $btnText = 'Login';
}
class UpdateUserForm extends FormComponent
{
public $title = 'Update User';
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