sohelamin / crud-generator

Laravel CRUD Generator
https://packagist.org/packages/appzcoder/crud-generator
MIT License
1.41k stars 426 forks source link

Custom default value #132

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hello, I want to format datetime but I don't know how to do it.

{!! Form::label('expire', 'Ex', ['class' => 'col-md-3 control-label']) !!}
{!! Form::input('datetime-local', 'expire', null, ['class' => 'form-control','dir' => 'ltr']) !!} {!! $errors->first('expire', '

:message

') !!}

now I want to add a function to format datetime for my application.

jonashamm commented 8 years ago

Hi! Maybe you can tell us a bit more: when do you want to format it? When the user comes to the page there ought to be already a default value in the correct format? Or has it to be formatted, when the field is submitted to the database? Or something else? :) Maybe this helps you: https://laravelcollective.com/docs/5.3/html#date or this: http://andrewhuggins.com/blog/working-with-datetime-field-in-laravel

Anyway, I'm trying to make a version of the crud generator package with removed dependencies for bootstrap and laravel collective modules. Maybe it's easier then for you to format custom values.

ghost commented 8 years ago

Hello, Thanks for your package.

For example in table I have modified date like: 2015-10-10 Now I want to change this to Jalali on display and convert to 2015-10-10 on save.

jonashamm commented 8 years ago

I think for this you need a package like this: https://github.com/sallar/jDateTime - but this is unmaintained. There's a link to this one: http://farhadi.ir/blog/1389/02/10/persian-calendar-for-php-53/ I don't understand that page, but probably you do :)

I think then you have to do something like: {!! Form::input('datetime-local', 'expire', $your_item_name_here->expire->format('Y-m-d\TH:i')) !!} ... with the desired format and according to the instructions on http://farhadi.ir/blog/1389/02/10/persian-calendar-for-php-53/ (untested)

The conversion back to 2015-10-10 format before writing to the database should be done in the Controller I think.

sohelamin commented 8 years ago

Check issue #137