Skip to content

Commit

Permalink
Test commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulSpr committed Jan 16, 2016
0 parents commit 0b5250e
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 0 deletions.
23 changes: 23 additions & 0 deletions composer.json
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"
}
7 changes: 7 additions & 0 deletions src/Paulspr/FormSet/Facade.php
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'; }

}
86 changes: 86 additions & 0 deletions src/Paulspr/FormSet/FormSet.php
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);
}

}
98 changes: 98 additions & 0 deletions src/Paulspr/FormSet/FormSetServiceProvider.php
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();
}

}

0 comments on commit 0b5250e

Please sign in to comment.