diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..f52ce91 --- /dev/null +++ b/composer.json @@ -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": "paul@interactivestudios.nl" + } + ], + "require": { + "php": ">=5.3.0", + "laravelcollective/html": "5.*", + "paulspr/laravalid": ">=1.0" + }, + "autoload": { + "psr-0": { + "Paulspr\\FormSet\\": "src/" + } + }, + "minimum-stability": "stable" +} diff --git a/src/Paulspr/FormSet/Facade.php b/src/Paulspr/FormSet/Facade.php new file mode 100644 index 0000000..88425b5 --- /dev/null +++ b/src/Paulspr/FormSet/Facade.php @@ -0,0 +1,7 @@ +converter->convert(Helper::getFormAttribute($name)) + $options; + return parent::text($name, $value, $options); + } + + + public function makeSet( $label, $input ){ + return ' +
+
+ '.$label.' +
+
+ '.$input.' +
+
'; + } + + + 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); + } + +} \ No newline at end of file diff --git a/src/Paulspr/FormSet/FormSetServiceProvider.php b/src/Paulspr/FormSet/FormSetServiceProvider.php new file mode 100644 index 0000000..310510c --- /dev/null +++ b/src/Paulspr/FormSet/FormSetServiceProvider.php @@ -0,0 +1,98 @@ +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(); + } + +}