WTForms- RadioField无法选择

时间:2018-06-11 18:48:28

标签: flask-wtforms wtforms

有没有办法不要求用户在RadioField中选择一个选项?即使没有验证器,它也总是返回"不是有效的选择"

1 个答案:

答案 0 :(得分:1)

这是答案:

set currentPageNumber(val) {
  if (!Number.isInteger(val)) {
    throw new Error('Invalid page number.');
  }
  if (!this.pdfDocument) {
    return;
  }
  // The intent can be to just reset a scroll position and/or scale. 
  this._setCurrentPageNumber(val, /* resetCurrentPageView = */ true);
}

/** 
 * @private 
 */
_setCurrentPageNumber(val, resetCurrentPageView = false) {
  if (this._currentPageNumber === val) {
    if (resetCurrentPageView) {
      this._resetCurrentPageView();
    }
    return;
  }

  if (!(0 < val && val <= this.pagesCount)) {
    console.error(
      `${this._name}._setCurrentPageNumber: "${val}" is out of bounds.`);
    return;
  }

  let arg = {
    source: this,
    pageNumber: val,
    pageLabel: this._pageLabels && this._pageLabels[val - 1],
  };
  this._currentPageNumber = val;
  this.eventBus.dispatch('pagechanging', arg);
  this.eventBus.dispatch('pagechange', arg);

  if (resetCurrentPageView) {
    this._resetCurrentPageView();
  }
}

感谢attack68的建议。