== Introduction ==

The parent recipe to this one ([[Data-aware Controls with Validators, demonstrated in a dialog]]) shows general, simple means for making controls data-aware. However, in that recipe only the most entirely straightforward controls, textboxes and checkboxes, were considered. This one shows how to provide data-aware extensions of the `CalendarCtrl` control, which lacks the abiltity to support wxPython's usual validation machinery.

== What Objects are Involved ==

The factory called `DerivedDBControl` can be used to create data-aware controls that "need to know more" about what they are to do than do textboxes.

For example, the line of code that appears first below indicates how to create a data-aware version of the `CalendarCtrl` object that is able to accept and store Null date values to a database.

== Process Overview ==

Typically a reference to such an object would be placed in the 'control' member of a dictionary entry describing a single GUI database field. Notice the reference to `Calendar` object in the `workorderFieldsInfo`, which is used in the parent recipe to this one. Notice also that `validator` is set to `None` for fields that use this control.

== Concerns ==

The derived control supports persistence only to databases that accept ISO-format dates, eg, MySQL.

== Code Sample ==

{{{
#!python
from wxPython.wx import *
from wx . calendar import  *
    
Calendar = DerivedDBControl ( CalendarCtrlForDB, kwargs = { 'style': CAL_SUNDAY_FIRST | CAL_SEQUENTIAL_MONTH_SELECTION | CAL_SHOW_SURROUNDING_WEEKS } )
OrderTypeComboxBox = DerivedDBControl ( wxComboBox, kwargs = { 'value': '', 'choices': [ 'L', 'M', ], } ) 
workorderFieldsInfo . rawInfo = {
    'IDENTIFIER' : { 'DisplayName': 'Identifier', 'NoDisplay': True, 'readOnly': True, },
    'ORD_DATE' : { 'DisplayName' : 'Order Date', 'control': Calendar, 'validator' : None, },
    'CUST_NO' : { 'DisplayName' : 'Customer Number', 'readOnly': True, },
    'INV_AMT' : { 'DisplayName' : 'Invoice Amount', },
    'WO_NO' : { 'DisplayName' : 'WO Number', },
    'INV_NO' : { 'DisplayName' : 'Invoice Number', },
    'PO_NO' : { 'DisplayName' : 'PO Number', },
    'PAID_DATE' : { 'DisplayName' : 'Paid Date', 'control': Calendar, 'validator' : None, },
    'PAID_FLAG' : { 'DisplayName' : 'Paid Flag', },
    'ORD_TYPE' : { 'DisplayName' : 'Units', 'control': OrderTypeComboxBox, },
    'UTILITY' : { 'DisplayName' : 'Utility', },
    }

}}}

=== Comments ===

I welcome comment. [[Bill Bell]]