Giter Club home page Giter Club logo

laravel-form-base-model's People

Contributors

anaxamaxan avatar lucadegasperi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-form-base-model's Issues

Foods is Undefined.

On the review page of the multi_page example, here is the error :

Unhandled Exception
Message:

Undefined variable: foods

Location:

/Applications/MAMP/htdocs/laravel/laravel/view.php(354) : eval()'d code on line 30

Stack Trace:

#0 /Applications/MAMP/htdocs/laravel/laravel/laravel.php(40): Laravel\Error::native(8, 'Undefined varia...', '/Applications/M...', 30)
#1 /Applications/MAMP/htdocs/laravel/laravel/view.php(354) : eval()'d code(30): Laravel\{closure}(8, 'Undefined varia...', '/Applications/M...', 30, Array)
#2 /Applications/MAMP/htdocs/laravel/laravel/view.php(354): eval()
#3 /Applications/MAMP/htdocs/laravel/laravel/blade.php(71): Laravel\View->get()
#4 [internal function]: Laravel\{closure}(Object(Laravel\View))
#5 /Applications/MAMP/htdocs/laravel/laravel/event.php(199): call_user_func_array(Object(Closure), Array)
#6 /Applications/MAMP/htdocs/laravel/laravel/event.php(138): Laravel\Event::fire('laravel.view.en...', Array, true)
#7 /Applications/MAMP/htdocs/laravel/laravel/view.php(325): Laravel\Event::until('laravel.view.en...', Array)
#8 /Applications/MAMP/htdocs/laravel/laravel/view.php(546): Laravel\View->render()
#9 /Applications/MAMP/htdocs/laravel/laravel/response.php(246): Laravel\View->__toString()
#10 /Applications/MAMP/htdocs/laravel/laravel/laravel.php(138): Laravel\Response->render()
#11 /Applications/MAMP/htdocs/laravel/public/index.php(34): require('/Applications/M...')
#12 {main}

Adding internationalised validation messages

Hey Shawn,

I've been puzzling over how to add internationalised messages to the form model.

I know I can create the $messages array in the form model, but I can't pull in Lang::line function results (PHP fundamentals at issue here).

public static $messages = array(
    'test_required' => 'This is a custom message that will render',
    'test2_required' => __('message.this_throws_a_php_error'),
);

So I thought I'd try handling it in the __construct using something like:

public function __construct() {
    $this->messages['test_required'] = __('messages.custom');
}

But this does nothing. This probably isn't an issue with the plugin itself but more a way of passing Lang returns to a static variable declared in a class.

Perhaps there's another way around it but I haven't found anything yet.

Any advice much appreciated!
Cheers,
Alex

get method nulls 0 value

Hey Shawn,

I've just encountered an issue using ::get().

I have a form model called RegistrationForm

In step one post I do a sample:

RegistrationForm::set('test', 0);

Then in step two get I run:

var_dump(RegistrationForm::all());
var_dump(RegistrationForm::get('test'));

And that outputs

array(1) {
    ["test"]=>int(0)
}

NULL

This causes me an issue using either bool or int inputs on the registration form. I can get around it at the moment by assigning RegistrationForm::all() to a variable and just picking the values from there, but it looked like an issue to me so I thought I'd post it here.

Cheers!
Alex

Escaping, htmlentities, strip_tags before final submission

Hey Shawn,

Originally I was escaping inputs like name, description etc at the final form post, but I realised that this doesn't take effect until after the review stage. Now whilst the review stage is only visible to the person submitting the multi-step form I'd still prefer to escape these inputs as soon as they're submitted.

So step one user enters a html link as their name, if they go back to step one I want to have already run strip_tags and htmlentities etc on the field.

I'm not sure how to achieve this with the form base model as my post_step_one controller just lists the fields to be collected as an array.

Is it something that can be done in before_validation?

If so perhaps you could be kind enough to give a little hint as to how to do it?

Cheers!
Alex

Save_input does not work correctly

Hi,

we just figured out that there is an error in your save_input() method of line 193 when you pass an input parameter to this method.

It should be
static::set( $field_name, array_key_exists($field_name, $input) ? $input[$field_name] : '' );

since you refer to $input on line178 (but never use $input later on)
if( is_null( $input ) )
$input = Input::all();

Above line will fix this issue.

Can you please add this to this great bundle.
Thanks,
Dennis

Feature : Load from DB

Hi Shawn.

I'm still enjoying the model and playing with it.

In order to make the model even more abstract and reusable, do you see a way to set default values from a DB query ?

I've tried the following but my category:all() is returned empty.

    public static $categories = array();

    public function __construct()
    {

        echo '<pre>';
        print_r(Category::all());
        echo '</pre>';

        static::$categories = Category::all();
    }

May it be because the FormModel is called before any Database call ?

Cheers.

Error on laravel 3.2.1

Not sure if this is example code or what the issue is here, but this is what I get when accessing page 2 of your multipage example.

Array to string conversion

Location:

E:\backup\xampp\htdocs\laravel\laravel\input.php on line 43

Stack Trace:

#0 E:\backup\xampp\htdocs\laravel\laravel\laravel.php(40): Laravel\Error::native(8, 'Array to string conversion', 'E:\backup\xampp\htdocs\laravel\laravel\input.php', 43)
#1 E:\backup\xampp\htdocs\laravel\laravel\input.php(43): Laravel\{closure}(8, 'Array to string conversion', 'E:\backup\xampp\htdocs\laravel\laravel\input.php', 43, Array)
#2 E:\backup\xampp\htdocs\laravel\bundles\form-base-model\formbase_model.php(186): Laravel\Input::has('favorite_foods')
#3 E:\backup\xampp\htdocs\laravel\bundles\form-base-model\controllers\examples.php(108): FormBase_Model::save_input(Array)
#4 [internal function]: Form_Base_Model_Examples_Controller->post_multi_page_example_two()
#5 E:\backup\xampp\htdocs\laravel\laravel\routing\controller.php(323): call_user_func_array(Array, Array)
#6 E:\backup\xampp\htdocs\laravel\laravel\routing\controller.php(283): Laravel\Routing\Controller->response('multi_page_example_two', Array)
#7 E:\backup\xampp\htdocs\laravel\laravel\routing\controller.php(165): Laravel\Routing\Controller->execute('multi_page_example_two', Array)
#8 E:\backup\xampp\htdocs\laravel\laravel\routing\route.php(153): Laravel\Routing\Controller::call('form-base-model::examples@(:1)', Array)
#9 E:\backup\xampp\htdocs\laravel\laravel\routing\route.php(124): Laravel\Routing\Route->response()
#10 E:\backup\xampp\htdocs\laravel\laravel\laravel.php(125): Laravel\Routing\Route->call()
#11 E:\backup\xampp\htdocs\laravel\public\index.php(34): require('E:\backup\xampp\htdocs\laravel\laravel\laravel.php')

save_input() returns no errors.

So when I use:

return Redirect::back()->with_input()->with_errors( PropertyForm::$validation );
I get no rule errors, but redirects with input

But

PropertyForm::save_input();
return Redirect::back()->with_errors( PropertyForm::$validation );

returns rule errors

Is this the way form-base-model is supposed to be used without with_input?

Thx for this great bundle.

Laravel 4

Is this project dead ? Is there any plan on migrating it to packagist ?

Method old() does not return a value when html input is having multi-dimension array.

The dot syntax does not work, when having HTML input arrays such as the following for example,

Model


class User extends FormBaseModel\Base {
    public static $rules = array(
        'user.email' => 'required|email',
    );
}

Controller


class User_Controllers extends Controller {
    // ...
    public function post_index()
    {
         if( ! User::is_valid()) {
              return Redirect::back()->with_input()
              ->with_errors(User::$validation)
              ;
         }
         else {
              // ...
         }
    }
}

This seems to return null,

{{ Form::text('user[email]', User::old('user.email') }}
{{ $errors->has('user.email') ? $errors->first('user.email', '<p class="help-block">:message</p>') : '' }}

In contrast to that, this will return old input.

{{ Form::text('user[email]', Input::old('user.email') }}
{{ $errors->has('user.email') ? $errors->first('user.email', '<p class="help-block">:message</p>') : '' }}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.