Disabled field handling

rsm08 - April 25, 2009 - 17:03
Project:Ubercart Auction
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:minor
Assigned:Unassigned
Status:active
Description

Hi Garrett

I was looking at the current solution for disabling the start price field for running auctions, which you describe in the code:

// The user can only change the start_price when a product is not currently
// being auctioned. The other times, we display it as a disabled textfield.
// However, since disabled fields are not submitted by browsers, we need
// to submit a value of the start_price when that is the case. If it is,
// then we've already given start_price a #type of 'value' above, along with
// other attributes which are used for textfields but not for values. Let's
// duplicate that to make the visible (but disabled) textfield.

I was just wondering why you change the field type to 'value' and make a "fake" start price field to show as disabled, when the value isn't used in the 'update' op of hook_nodeapi anyway? Why not just disable the start price field?

#1

Garrett Albright - April 27, 2009 - 15:55

Because the price field may be used in the 'validate' op, at which point we don't know what the auction state of the product is. At least, I think that was the reason…

Truth be told, really, that part of the code could use some reworking. I'm using hook_nodeapi() to do too much, so that there's a few hacky things here and there like that.

#2

rsm08 - April 27, 2009 - 16:29

Ok I found out why. The validation will fail if the start price field is empty. So it's reasonable enough I guess.

 
 

Drupal is a registered trademark of Dries Buytaert.