crudkit icon indicating copy to clipboard operation
crudkit copied to clipboard

Problem with date or datetime or timestamp in field type

Open SomdipSanyal opened this issue 9 years ago • 7 comments

Please fix this date field is not coming

SomdipSanyal avatar Dec 28 '15 20:12 SomdipSanyal

Ok. I'll look into it... Thanks!

skyronic avatar Dec 29 '15 09:12 skyronic

date is still not working and timestamp doesn't really work either. When attempting to add a new record the timestamp field shows up but the entry mechanism is broken.

jnierodzik avatar Apr 19 '17 18:04 jnierodzik

I have the same problem too.

MR-GamBit avatar Jul 03 '17 13:07 MR-GamBit

@MR-GamBit - is your field of type 'date' not 'datetime'?

It doesn't seem to handle date fields very well, but if you change the fields type from self::TYPE_DATE to self::TYPE_DATETIME it seems to be all cool again.

Not a particularly elegant fix, but it gets date fields working.

harryspink avatar Jul 04 '17 12:07 harryspink

Hello any update about this issue? I use datetime as suggested above, but it seems the <datepicker .../> seems not rendered correctly. Just display tiny gray disabled box.

stevanus-christopel avatar Dec 10 '17 14:12 stevanus-christopel

I did the following and the datepicker showed up, but date only...

  1. Download ui-bootstrap-tpls-0.13.0.min.js and put under static/crudkit/js/
  2. Add the line below to requires_prod.twig

Also if I modify prepareForClient() in SQLColumn.php to like this: case "datetime":case "date":case "timestamp": return $value; The view_item will show datetime correctly, but the edit_item will be screwed. If I change it back to then edit_item will show correctly but view_item will be wrong. Hopefully someone sees this and can help fix this datetime issue, this is a wonderful project but such a pity...

bclin087 avatar Nov 02 '18 11:11 bclin087

follow up:

  • add the attached file (taken and modified from https://angular-ui.github.io/bootstrap/versioned-docs/0.13.0/) to static/crudkit/js (remove the .txt extension)

datetime-fix.js.txt

  • add the include in requires_prod.twig:
  • in DateTimeForItem.php, change renderInternal to this: public function renderInternal() { $directives = $this->getAngularDirectives (); return <<<COMP

    <input type="text" class="form-control" datepicker-popup="{{format}}" $directives is-open="opened" datepicker-options="dateOptions" date-disabled="disabled(date, mode)" ng-required="true" close-text="Close" />

    COMP; }
  • now the datepicker will show as a pop-up when button pressed, and editing datetime would work.

  • Still can't find a way to fix prepareForClient() in SQLColumn.php so that View and Edit datetime can both work.

bclin087 avatar Nov 04 '18 18:11 bclin087