PHP code example of elnooronline / laravel-bootstrap-forms
1. Go to this page and download the library: Download elnooronline/laravel-bootstrap-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/ */
elnooronline / laravel-bootstrap-forms example snippets
return [
'attributes' => [
'username' => 'User Name',
'email' => 'E-mail Address',
'phone' => 'Phone Number',
],
'notes' => [
'username' => 'Example: Ahmed Fathy',
'email' => 'Example: [email protected]',
'phone' => 'Example: +02xxxxxxxxxxx',
],
'placeholders' => [
'username' => 'Please enter your name.',
'email' => 'Please enter your e-mail address.',
'phone' => 'Please enter your phone number.',
],
...
];
// Default error bag
BsForm::errorBag('default');
// Other error bag
BsForm::errorBag('create');
return [
/**
* The path of form components views.
*
* - 'BsForm::bootstrap4' - Bootstrap 4
* - 'BsForm::bootstrap3' - Bootstrap 3
*/
'views' => 'BsForm::bootstrap3',
];
namespace App\Components;
use Elnooronline\LaravelBootstrapForms\Components\BaseComponent;
class ImageComponent extends BaseComponent
{
/**
* The component view path.
*
* @var string
*/
protected $viewPath = 'components.image';
/**
* The image file path.
*
* @var string
*/
protected $file;
/**
* Initialized the input arguments.
*
* @param null $name
* @param null $file
* @return $this
*/
public function init($name = null, $file = null)
{
$this->name = $name;
$this->value = $file ?: 'http://via.placeholder.com/100x100';
//$this->hasDefaultLocaledLabel($name);
//$this->hasDefaultLocaledNote($name);
//$this->hasDefaultLocaledPlaceholder($name);
return $this;
}
/**
* Set the file path.
*
* @param $file
* @return $this
*/
public function file($file)
{
$this->file = $file;
return $this;
}
/**
* The variables with registerd in view component.
*
* @return array
*/
protected function viewComposer()
{
return [
'file' => $this->file,
];
}
}
namespace App\Providers;
use App\Components\ImageComponent;
use Illuminate\Support\ServiceProvider;
use Elnooronline\LaravelBootstrapForms\Facades\BsForm;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
BsForm::registerComponent('image', ImageComponent::class);
...
}
...