-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0b5250e
Showing
4 changed files
with
214 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "paulspr/formset", | ||
"description": "This package enables you the easily create sets of form labels and forms fields wrapped in Foundation related classes.", | ||
"keywords" : ["laravel","laravel5","validation","laravel validation","client-side","client side","laravel validation converter","laravel validation for client-side", "jquery validation", "bootstrap validation"], | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Paul Sprangers", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.3.0", | ||
"laravelcollective/html": "5.*", | ||
"paulspr/laravalid": ">=1.0" | ||
}, | ||
"autoload": { | ||
"psr-0": { | ||
"Paulspr\\FormSet\\": "src/" | ||
} | ||
}, | ||
"minimum-stability": "stable" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php namespace Bllim\Laravalid; | ||
|
||
class Facade extends \Illuminate\Support\Facades\Facade { | ||
|
||
protected static function getFacadeAccessor() { return 'formset'; } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
namespace Paulspr\FormSet; | ||
|
||
class FormBuilder extends \Bllim\Laravalid\FormBuilder { | ||
|
||
public function postalcode($name, $value = null, $options = []) | ||
{ | ||
if(isset($options['class'])){ | ||
$options['class'] .= ' postalcodeNL'; | ||
} | ||
else{ | ||
$options['class'] = 'postalcodeNL'; | ||
} | ||
$options = $this->converter->convert(Helper::getFormAttribute($name)) + $options; | ||
return parent::text($name, $value, $options); | ||
} | ||
|
||
|
||
public function makeSet( $label, $input ){ | ||
return ' | ||
<div class="row is-form-row"> | ||
<div class="is-form-label-holder"> | ||
'.$label.' | ||
</div> | ||
<div class="is-form-widget-holder"> | ||
'.$input.' | ||
</div> | ||
</div>'; | ||
} | ||
|
||
|
||
public function textSet($name, $options = [], $value = null){ | ||
return self::inputSet('text', $name, $value, $options); | ||
} | ||
public function passwordSet($name, $options = [], $value = null){ | ||
return self::inputSet('password', $name, $value, $options); | ||
} | ||
public function emailSet($name, $options = [], $value = null){ | ||
return self::inputSet('email', $name, $value, $options); | ||
} | ||
public function telSet($name, $options = [], $value = null){ | ||
return self::inputSet('tel', $name, $value, $options); | ||
} | ||
public function numberSet($name, $options = [], $value = null){ | ||
return self::inputSet('number', $name, $value, $options); | ||
} | ||
|
||
public function dateSet($name, $options = [], $value = null){ | ||
return self::inputSet('date', $name, $value, $options); | ||
} | ||
public function datetimeSet($name, $options = [], $value = null){ | ||
return self::inputSet('datetime', $name, $value, $options); | ||
} | ||
public function datetimeLocalSet($name, $options = [], $value = null){ | ||
return self::inputSet('datetime-local', $name, $value, $options); | ||
} | ||
|
||
public function timeSet($name, $options = [], $value = null){ | ||
return self::inputSet('time', $name, $value, $options); | ||
} | ||
public function urlSet($name, $options = [], $value = null){ | ||
return self::inputSet('url', $name, $value, $options); | ||
} | ||
public function fileSet($name, $options = [], $value = null){ | ||
return self::inputSet('file', $name, $value, $options); | ||
} | ||
|
||
public function postalcodeSet($name, $options = [], $value = null){ | ||
$customInput = self::postalcode($name, $value, $options); | ||
return self::inputSet('text', $name, $value, $options, $customInput); | ||
} | ||
|
||
|
||
public function inputSet($type, $name, $value = null, $options = [], $customInput = null){ | ||
$options = $this->converter->convert(Helper::getFormAttribute($name)) + $options; | ||
|
||
$labelText = isset($options['label']) ? $options['label'] : null; | ||
$requiredLabel = isset($options['data-rule-required']) ? self::$requiredLabel : ''; | ||
|
||
$label = self::label($name, $labelText, [], $requiredLabel); | ||
$input = isset($customInput) ? $customInput : parent::input($type, $name, $value, $options); | ||
return self::makeSet($label, $input); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
|
||
namespace Paulspr\FormSet; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
|
||
class FormSetServiceProvider extends ServiceProvider { | ||
|
||
/** | ||
* Indicates if loading of the provider is deferred. | ||
* | ||
* @var bool | ||
*/ | ||
protected $defer = false; | ||
|
||
/** | ||
* Bootstrap the application events. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
// $this->publishes([ | ||
// __DIR__.'/../../../config' => config_path('laravalid'), | ||
// ], 'config'); | ||
// | ||
// $this->publishes([ | ||
// __DIR__.'/../../../public' => public_path('laravalid'), | ||
// ], 'public'); | ||
// | ||
// $routeName = \Config::get('laravalid.route'); | ||
// | ||
// // remote validations | ||
// \Route::any($routeName.'/{rule}', '\Bllim\Laravalid\RuleController@getIndex'); | ||
} | ||
|
||
/** | ||
* Register the service provider. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
// $this->registerResources(); | ||
|
||
error_log('TEST TEST'); | ||
|
||
if(!isset($this->app['html'])) | ||
{ | ||
$this->app->singleton('html', function($app) | ||
{ | ||
return new \Collective\Html\HtmlBuilder($app['url'], $app['view']); | ||
}); | ||
} | ||
|
||
$this->app->singleton('formset', function ($app) { | ||
$plugin = \Config::get('formset.plugin'); | ||
$converterClassName = 'Bllim\Laravalid\Converter\\'.$plugin.'\Converter'; | ||
$converter = new $converterClassName(); | ||
|
||
$form = new FormBuilder($app->make('html'), $app->make('url'), $app->make('session.store')->getToken(), $converter, $app['view']); | ||
return $form->setSessionStore($app->make('session.store')); | ||
} | ||
); | ||
} | ||
|
||
/** | ||
* Register the package resources. | ||
* | ||
* @return void | ||
*/ | ||
protected function registerResources() | ||
{ | ||
/* | ||
$userConfigFile = app()->configPath().'/laravalid/config.php'; | ||
$packageConfigFile = __DIR__.'/../../../config/config.php'; | ||
$config = $this->app['files']->getRequire($packageConfigFile); | ||
if (file_exists($userConfigFile)) { | ||
$userConfig = $this->app['files']->getRequire($userConfigFile); | ||
$config = array_replace_recursive($config, $userConfig); | ||
} | ||
$this->app['config']->set('laravalid', $config); | ||
*/ | ||
} | ||
|
||
/** | ||
* Get the services provided by the provider. | ||
* | ||
* @return array | ||
*/ | ||
public function provides() | ||
{ | ||
return array(); | ||
} | ||
|
||
} |