   validate: (options = {})->
     @checkErrors()
     @refreshErrorsDisplay(options)
+    !@errors.length
 
   checkErrors: ->
     @errors = []
-    console.log 'CHECK ERRORS'
-    console.log 'sellable_id', @$('[name$="[sellable_id]"]').val(), @sellableChosen()
-    console.log 'quantity', @$('[name$="[quantity]"]').val(), @quantityFilled()
-
     @errors.push('choose') unless @sellableChosen()
     @errors.push('quantity') unless @quantityFilled()
 

  displayErrorMessages: (options) ->
    messages = (@errorMessages[error] for error in @errors)
    message = messages.join('<br>')
    @$button.attr(title: message)
    @$button.tooltip(html: true)
    # Force tooltip display if the user just submitted the form
    @$button.tooltip('show') if options.submit
    @$button.prop('disabled', true)

class Stall.AddToCartForm extends Vertebra.View
  @create = ($el) ->
    unless (form = $el.data('stall.add-to-cart-form'))
      form = new Stall.AddToCartForm(el: $el)
      $el.data('stall.add-to-cart-form', form)

    form

  @validate = ($el) ->
    form = Stall.AddToCartForm.create($el)
    form.validate()

  @sendRequest = ($el) ->
    form = Stall.AddToCartForm.create($el)
    form.sendRequest()

  events:
    'ajax:success': 'onSuccess'
