Yii Framework Forum: [BUG] Form dateField and default value in MSSQL - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[BUG] Form dateField and default value in MSSQL Rate Topic: -----

#1 User is offline   hastenax 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 27-February 12

Posted 24 August 2012 - 04:53 AM

When using dateField method with MSSQL database it produce next HTML:

<input name="Cost[DateOrder]" id="Cost_DateOrder" type="date" value="1995-09-01 00:00:00.000">


This last time part in value attribute prevent browser to correctly display default value. Chrome displays nothing. I know that in MySQL we can use DATE field, but MSSQL doesn't have it, it always provides data with time part.

Any ideas? This is unexpected behavior of yii(bug), in MySQL all is working. In MSSQL dateField implemented in 1.1.11 not working at all.
0

#2 User is offline   dimitri 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 14-August 12
  • Location:Estonia, Tallinn

Posted 24 August 2012 - 05:40 AM

I believe that this is not Yii bug. It is just one more illogical behavior of MSSQL.
I also working with PHP/MSSQL for a plenty of time. So, I got used to implement different workarounds.
Fortunately, Yii and PHP in general are flexible enough to do this.
0

#3 User is offline   hastenax 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 27-February 12

Posted 24 August 2012 - 06:27 AM

View Postdimitri, on 24 August 2012 - 05:40 AM, said:

I believe that this is not Yii bug. It is just one more illogical behavior of MSSQL.
I also working with PHP/MSSQL for a plenty of time. So, I got used to implement different workarounds.
Fortunately, Yii and PHP in general are flexible enough to do this.


Different workarounds for simple dateFields is not a good idea, I believe.
0

#4 User is offline   dimitri 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 14-August 12
  • Location:Estonia, Tallinn

Posted 24 August 2012 - 07:30 AM

Yes, you are right.
However, the described problem comes from the MS SQL database engine. For me, it is not normal then you are using type 'date' and the database engine returns to you 'datetime' value.

There are three ways how to solve this problem:
1) Implement a workaround in your own code,
2) Beg developers to implement workaround in the Yii code,
3) Beg Microsoft to do something with this :).

There are pros and cons of both ways.
But, definitely, this is not a Yii bug.

Best wishes.
0

#5 User is offline   hastenax 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 27-February 12

Posted 24 August 2012 - 09:45 AM

View Postdimitri, on 24 August 2012 - 07:30 AM, said:

Yes, you are right.
However, the described problem comes from the MS SQL database engine. For me, it is not normal then you are using type 'date' and the database engine returns to you 'datetime' value.

There are three ways how to solve this problem:
1) Implement a workaround in your own code,
2) Beg developers to implement workaround in the Yii code,
3) Beg Microsoft to do something with this :).

There are pros and cons of both ways.
But, definitely, this is not a Yii bug.

Best wishes.


One little moment (which cause the problem) - MSSQL doesn't have DATE field type! I don't mind, you can name it on your own, but $form->dateField don't working with MSSQL.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users