diff --git a/app/Providers/FormFieldServiceProvider.php b/app/Providers/FormFieldServiceProvider.php
deleted file mode 100644
index 4a2ad69..0000000
--- a/app/Providers/FormFieldServiceProvider.php
+++ /dev/null
@@ -1,29 +0,0 @@
-app->alias(FormField::class, 'formField');
- }
-}
diff --git a/app/Services/Facades/FormField.php b/app/Services/Facades/FormField.php
deleted file mode 100644
index bdb4d42..0000000
--- a/app/Services/Facades/FormField.php
+++ /dev/null
@@ -1,10 +0,0 @@
-errorBag = Session::get('errors', new MessageBag);
- }
-
- public function text($name, $options = [])
- {
- $hasError = $this->errorBag->has($name) ? 'has-error' : '';
- $htmlForm = '
';
-
- return $htmlForm;
- }
-
- public function textarea($name, $options = [])
- {
- $hasError = $this->errorBag->has($name) ? 'has-error' : '';
- $htmlForm = '';
-
- $rows = isset($options['rows']) ? $options['rows'] : 3;
- $value = isset($options['value']) ? $options['value'] : null;
-
- $fieldParams = ['class'=>'form-control','rows' => $rows];
-
- if (isset($options['readonly']) && $options['readonly'] == true) { $fieldParams += ['readonly']; }
- if (isset($options['disabled']) && $options['disabled'] == true) { $fieldParams += ['disabled']; }
- if (isset($options['required']) && $options['required'] == true) { $fieldParams += ['required']; }
- if (isset($options['placeholder'])) { $fieldParams += ['placeholder' => $options['placeholder']]; }
-
- $htmlForm .= $this->setFormFieldLabel($name, $options);
-
- $htmlForm .= Form::textarea($name, $value, $fieldParams);
- $htmlForm .= $this->errorBag->first($name, ':message');
- $htmlForm .= '
';
-
- return $htmlForm;
- }
-
- public function select($name, $selectOptions, $options = [])
- {
- $hasError = $this->errorBag->has($name) ? 'has-error' : '';
- $htmlForm = '';
-
- $value = isset($options['value']) ? $options['value'] : null;
-
- $fieldParams = ['class'=>'form-control'];
- if (isset($options['class'])) { $fieldParams['class'] .= ' ' . $options['class']; }
-
- if (isset($options['readonly']) && $options['readonly'] == true) { $fieldParams += ['readonly']; }
- if (isset($options['disabled']) && $options['disabled'] == true) { $fieldParams += ['disabled']; }
- if (isset($options['required']) && $options['required'] == true) { $fieldParams += ['required']; }
- if (isset($options['multiple']) && $options['multiple'] == true) { $fieldParams += ['multiple', 'name' => $name . '[]']; }
- if (isset($options['placeholder']))
- $fieldParams += ['placeholder' => $options['placeholder']];
- else
- $fieldParams += ['placeholder' => '-- Pilih ' . str_split_ucwords(str_replace('_id', '', $name)) . ' --'];
-
- $htmlForm .= $this->setFormFieldLabel($name, $options);
-
- $htmlForm .= Form::select($name, $selectOptions, $value, $fieldParams);
- $htmlForm .= $this->errorBag->first($name, ':message');
-
- $htmlForm .= '
';
-
- return $htmlForm;
- }
-
- public function multiSelect($name, $selectOptions, $options = [])
- {
- $options['multiple'] = true;
-
- return $this->select($name, $selectOptions, $options);
- }
-
- public function email($name, $options = [])
- {
- $options['type'] = 'email';
- return $this->text($name, $options);
- }
-
- public function password($name, $options = [])
- {
- $options['type'] = 'password';
- return $this->text($name, $options);
- }
-
- public function radios($name, array $radioOptions, $options = [])
- {
- $hasError = $this->errorBag->has($name) ? 'has-error' : '';
-
- $htmlForm = '';
-
- return $htmlForm;
- }
-
- public function checkboxes($name, array $checkboxOptions, $options = [])
- {
- $hasError = $this->errorBag->has($name) ? 'has-error' : '';
- $htmlForm = '';
-
- return $htmlForm;
- }
-
- public function textDisplay($name, $value, $options = [])
- {
- $label = isset($options['label']) ? $options['label'] : str_split_ucwords($name);
-
- $htmlForm = '';
-
- return $htmlForm;
- }
-
- public function file($name, $options = [])
- {
- $hasError = $this->errorBag->has($name) ? 'has-error' : '';
- $label = isset($options['label']) ? $options['label'] : str_split_ucwords($name);
-
- $htmlForm = '';
-
- return $htmlForm;
- }
-
- public function delete($form_params = [], $button_label = 'x', $button_options = [], $hiddenFields = [])
- {
- $form_params['method'] = 'delete';
- $form_params['class'] = isset($form_params['class']) ? $form_params['class'] : 'del-form';
- $form_params['style'] = isset($form_params['style']) ? $form_params['style'] : 'display:inline';
-
- if (! isset($button_options['class']))
- $button_options['class'] = 'pull-right';
-
- if (! isset($button_options['title']))
- $button_options['title'] = 'Remove this';
-
- $htmlForm = Form::open($form_params);
- if (!empty($hiddenFields))
- {
- foreach ($hiddenFields as $k => $v)
- {
- $htmlForm .= Form::hidden($k, $v);
- }
- }
- $htmlForm .= Form::submit($button_label, $button_options);
- $htmlForm .= Form::close();
-
- return $htmlForm;
- }
-
- public function arrays($name, array $fieldKeys, $options = [])
- {
- $hasError = $this->errorBag->has($name) ? 'has-error' : '';
- $label = isset($options['label']) ? $options['label'] : str_split_ucwords($name);
-
- $htmlForm = '';
-
- return $htmlForm;
- }
-
- public function price($name, $options = [])
- {
- $options['addon'] = ['before' => isset($options['currency']) ? $options['currency'] : 'Rp'];
- $options['class'] = 'text-right';
- return $this->text($name, $options);
- }
-
- private function setFormFieldLabel($name, $options)
- {
- if (isset($options['label']) && $options['label'] != false) {
- $label = isset($options['label']) ? $options['label'] : str_split_ucwords($name);
- return Form::label($name, $label, ['class'=>'control-label']) . ' ';
- } elseif (! isset($options['label'])) {
- return Form::label($name, str_split_ucwords($name), ['class'=>'control-label']) . ' ';
- }
- }
-}
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 2838111..79593c8 100644
--- a/composer.json
+++ b/composer.json
@@ -9,7 +9,7 @@
"barryvdh/laravel-dompdf": "^0.7.0",
"intervention/image": "^2.3",
"laravel/framework": "5.4.*",
- "luthfi/formfield": "1.*",
+ "luthfi/formfield": "^0.1.6",
"laracasts/flash": "~2",
"laracasts/presenter": "^0.2.1",
"backup-manager/laravel": "^1.0",
diff --git a/composer.lock b/composer.lock
index 19430dc..44cdeff 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "content-hash": "2f401db91b0298fc38ade2c58a191657",
+ "content-hash": "9853f898a7ea6916d797832a1737a999",
"packages": [
{
"name": "backup-manager/backup-manager",
@@ -958,6 +958,46 @@
"time": "2016-12-28T01:30:30+00:00"
},
{
+ "name": "luthfi/formfield",
+ "version": "0.1.6",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/nafiesl/FormField.git",
+ "reference": "dfbbae8f86f6d332a9f548ad6cebc77e2c66810f"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/nafiesl/FormField/zipball/dfbbae8f86f6d332a9f548ad6cebc77e2c66810f",
+ "reference": "dfbbae8f86f6d332a9f548ad6cebc77e2c66810f",
+ "shasum": ""
+ },
+ "require": {
+ "illuminate/support": "5.3.* || 5.4.*",
+ "laravelcollective/html": "5.3.* || 5.4.*"
+ },
+ "require-dev": {
+ "orchestra/testbench": "~3.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Luthfi\\FormField\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nafies Luthfi",
+ "email": "nafiesl@gmail.com"
+ }
+ ],
+ "description": "Form Field helper class for Laravel 5.3 with Twitter Bootstrap",
+ "time": "2017-06-16T03:22:15+00:00"
+ },
+ {
"name": "maatwebsite/excel",
"version": "2.1.19",
"source": {
diff --git a/config/app.php b/config/app.php
index f197b52..382a53d 100644
--- a/config/app.php
+++ b/config/app.php
@@ -156,13 +156,12 @@ return [
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
App\Providers\EventServiceProvider::class,
- App\Providers\FormFieldServiceProvider::class,
App\Providers\OptionServiceProvider::class,
App\Providers\RouteServiceProvider::class,
BackupManager\Laravel\Laravel5ServiceProvider::class,
- Collective\Html\HtmlServiceProvider::class,
Laracasts\Flash\FlashServiceProvider::class,
+ Luthfi\FormField\FormFieldServiceProvider::class,
Maatwebsite\Excel\ExcelServiceProvider::class,
Spatie\Fractal\FractalServiceProvider::class,
],
@@ -214,11 +213,11 @@ return [
'Carbon' => Carbon\Carbon::class,
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
'Fractal' => Spatie\Fractal\FractalFacade::class,
+ 'Option' => App\Services\Facades\Option::class,
+
+ 'FormField' => Luthfi\FormField\FormFieldFacade::class,
'Form' => Collective\Html\FormFacade::class,
- 'FormField' => App\Services\Facades\FormField::class,
'Html' => Collective\Html\HtmlFacade::class,
- 'Flash' => Laracasts\Flash\Flash::class,
- 'Option' => App\Services\Facades\Option::class,
],