Hi
I am trying to validate my page using multiple validate decorators and it
seems a though only the first 2 validators do anything. Any validators
after that don't seem to get called.
Here is what I'm doing and why I (think I) need to do this:
I have 1 page with 4 tabber pages on it. I created a class called
TabularFields which extends TableForm. I did this because I applied a
different template to it, the only change being that I stripped the <form>,
</form> and <input type="submit"> stuff out of it. I did this because I
have 4 'sets' of data that I want submitted at the same time to the
database.
My data fields to display on the page look like this:
class RequisitionRequestFields(WidgetsList):
plant = SingleSelectField(label='Plant:', options=getPlantOptions)
requisitionPeriod = SingleSelectField(label='Period:',
options=getRequisitionPeriodOptions)
dateWeekEnds = CalendarDatePicker(label='For Week Ending:',
button_text='...', attrs=dict(size="10"))
requisitionStatus = SingleSelectField(label='Status:',
options=getRequisitionStatusOptions)
itemNumber = TextField(label='Item:', validator=validators.NotEmpty)
requestedBy = SingleSelectField(label='RequestedBy:',
options=getActiveUserOptions)
dateRequested = CalendarDatePicker(label='Requested On:',
button_text='...', attrs=dict(size="10"))
quantity = TextField(label='Quantity:', validator=validators.Int)
uom = TextField(label='Unit of Measure:', attrs=dict(size="5"),
validator=validators.NotEmpty)
dateCanHold = CalendarDatePicker(label='Can Hold On:',
button_text='...', attrs=dict(size="10"))
dateNeeded = CalendarDatePicker(label='Needed By:', button_text='...',
attrs=dict(size="10"))
class RequisitionOrderFields(WidgetsList):
supplier = SingleSelectField(label='Supplier:',
options=getSupplierOptions)
dateOrdered = CalendarDatePicker(label='Ordered On:', button_text='...',
attrs=dict(size="10"))
price = TextField(label='Price:')
poNumber = TextField(label='PO Number:')
class RequisitionShpRcvFields(WidgetsList):
quantityReceived = TextField(label='Qty Received:',
validator=validators.Int())
dateReceived = CalendarDatePicker(label='Received On:',
button_text='...', attrs=dict(size="10"))
carrier = SingleSelectField(label='Carrier:', options=getCarrierOptions)
bolNumber = TextField(label='BOL Number:', validator=validators.Int)
frtPoNumber = TextField(label='Frt PO Number:',
validator=validators.Int)
requisitionRequestFields = TabularFields(fields=RequisitionRequestFields())
requisitionOrderFields = TabularFields(fields=RequisitionOrderFields())
requisitionShpRcvFields = TabularFields(fields=RequisitionShpRcvFields())
requisitionNotesFields = TabularFields(fields=RequisitionNotesFields())
My kid template looks like this (abbreviated):
<form action="${action}" method="post" class="tableform" name="form">
<div xmlns:py="http://purl.org/kid/ns#" id="tabber" class="tabber">
<div
class="tabbertab"><h2>Request</h2>${requestInfo.display(value=values)}</div>
<div
class="tabbertab"><h2>Order</h2>${orderInfo.display(value=values)}</div>
<div
class="tabbertab"><h2>Shipping/Receiving</h2>${shippingInfo.display(value=va
lues)}</div>
<div
class="tabbertab"><h2>Notes</h2>${notesInfo.display(value=values)}</div>
</div>
<br />
<input type="submit" class="submitbutton" value="Save Changes" />
</form>
Then, in the controller I pass the following:
return dict(now=time.ctime(), menuLinks=self.menuLinks,
tabWidget=widgets.Tabber(),
requestInfo=widgets.requisitionRequestFields,
orderInfo=widgets.requisitionOrderFields,
shippingInfo=widgets.requisitionShpRcvFields,
notesInfo=widgets.requisitionNotesFields,
values=values, action=submitAction,
deleteLink=deleteLink)
Then when I try to update, I have these validate decorators:
@tg.validate(form=widgets.requisitionShpRcvFields)
@tg.validate(form=widgets.requisitionOrderFields)
@tg.validate(form=widgets.requisitionRequestFields)
@tg.validate(form=widgets.requisitionNotesFields)
The problem is that only the first two of them seem to do anything. If I
put them in a different order, it will always validate the first two only.
My question is whether or not there is a way that I can specify multiple
forms on the save validate decorator or if there is a better way to be doing
all of this or is there some known reason why only the first two validate
decorators run. Any help would be appreciated. I apologize for the large
post, but thought more information was better than none.
-Jim
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---