bradcornford / Bootstrapper

An easy way to integrate Twitter Bootstrap with Laravel
MIT License
23 stars 15 forks source link

Bootstrap::date field would be great #10

Closed seagullmouse closed 10 years ago

seagullmouse commented 10 years ago

Assume you'd use this as discussed.

http://www.eyecon.ro/bootstrap-datepicker/

Cheers mate!

bradcornford commented 10 years ago

I was actually considering implementing this version.

http://eonasdan.github.io/bootstrap-datetimepicker/

As it also has a time picker too, what do you think?

seagullmouse commented 10 years ago

Looks good to me!

Sent from my iPhone

On 24 May 2014, at 16:24, bradcornford notifications@github.com wrote:

I was actually considering implementing this version.

http://eonasdan.github.io/bootstrap-datetimepicker/

As it also has a time picker too, what do you think?

— Reply to this email directly or view it on GitHub.

bradcornford commented 10 years ago

This has now been introduced into the develop branch if you would like to give it a test. The new methods available are: Bootstrap::date() for a date field, Bootstrap::datetime() for a datetime field, Bootstrap::time() for a time field. The options are exactly the same as the text() method although an array can be passed as the final parameter to overwrite the JavaScript initialisation.

seagullmouse commented 10 years ago

What do I pass in as params to get it starting in year mode??? ta

bradcornford commented 10 years ago

array('viewMode' => 'year') if i remember correctly as the last parameter for the date() method.

seagullmouse commented 10 years ago

Cheers Bradley!!! And whats the format for opening a form that is horizontal with your bootstrap???

On 27 May 2014 18:30, Bradley Cornford notifications@github.com wrote:

array('viewMode' => 'year') if i remember correctly as the last parameter for the date() method.

— Reply to this email directly or view it on GitHubhttps://github.com/bradcornford/Bootstrapper/issues/10#issuecomment-44307733 .

bradcornford commented 10 years ago

I did add some comments onto your other issue, but for your reference its "Bootstrap::horizontal('col-sm-10', 'col-sm-2')->text('name', 'Value')" where the first parameter is the input class, the second is the label class.

seagullmouse commented 10 years ago

Sorry brad. I must have looked on the wrong ticket!!!

Sent from my iPhone

On 27 May 2014, at 20:01, Bradley Cornford notifications@github.com wrote:

I did add some comments onto your other issue, but for your reference its "Bootstrap::horizontal('col-sm-10', 'col-sm-2')->text('name', 'Value')" where the first parameter is the input class, the second is the label class.

— Reply to this email directly or view it on GitHub.

seagullmouse commented 10 years ago

Yo Bardley. Can't seem to get default date to set or change the format.

Tried passing in options to the js or to the input fields themselves

{{ Bootstrap::date('dob', 'Date of birth', (isset($profile->dob) ? $profile->dob : ""), $errors, array('class' => 'form-control', 'data-date-format' => 'YYYY-MM-DD')) }}

Any ideas?

bradcornford commented 10 years ago

I think you'll have to pass it as the final parameter to the date method, so array('defaultDate' => $profile->dob ?: ''). Well that's according to the options list on here: http://eonasdan.github.io/bootstrap-datetimepicker/

bradcornford commented 10 years ago

This seems to work for me: Bootstrap::date('dob', 'Date of birth', date('Y-m-d'), null, array('class' => 'form-control'), array('format' => 'YYYY-MM-DD')));

You can pass the 'data-date-' variables through the first array, as that adds the attributes onto the input element, not the container div.

seagullmouse commented 10 years ago

That all works now, its quite happy to pick up the default date from the input value. no idea why it didn't work earlier!

Cheers Bard!

On 1 June 2014 21:10, Bradley Cornford notifications@github.com wrote:

This seems to work for me: Bootstrap::date('dob', 'Date of birth', date('Y-m-d'), null, array('class' => 'form-control'), array('format' => 'YYYY-MM-DD')));

You can pass the 'data-date-' variables through the first array, as that adds the attributes onto the input element, not the container div.

— Reply to this email directly or view it on GitHub https://github.com/bradcornford/Bootstrapper/issues/10#issuecomment-44787775 .

seagullmouse commented 10 years ago

Ahhh code!

Line 245 in BootstrapBase, I think you have added a comma that causing a js error when you add a format and a viewmode together.

$return .= implode(', ', array_map(function ($value, $key) { return $key . ': "' . $value . '" '; }, $parameters, array_keys($parameters)));

Works well with 'viewMode' => 'years'!

bradcornford commented 10 years ago

Ah yes, that is now fixed and pushed to develop.

seagullmouse commented 10 years ago

If you have a new empty date field. It would be way better if focus/click showed the picker. I.e. at the moment if you don't click the date icon you don't see the calendar. What you reckon? should it fire automagically?

What ya think?

On 2 June 2014 20:22, Bradley Cornford notifications@github.com wrote:

Ah yes, that is now fixed and pushed to develop.

— Reply to this email directly or view it on GitHub https://github.com/bradcornford/Bootstrapper/issues/10#issuecomment-44879542 .

bradcornford commented 10 years ago

Here is the date picker base: http://www.eyecon.ro/bootstrap-datepicker/ Perhaps it has what you are looking for?

bradcornford commented 10 years ago

This has now been merged to master, and will be tagged in the next release. I'll look into adding something in, to allow input click to open the date picker.