0

毎日がSymfonyの新しい日ですが、私はそれが大好きです!今朝私はをインストールしましたsfJQueryUIPlugin。依存関係はほとんどなく、themeRollerスタイルを受け入れます。ただし、2つの問題があります。

[Feature_Request]年の範囲を指定する方法はありません。デフォルトでは、フィールド値に1年前後の20年の範囲が表示されます。例えば。フィールド値が1993-01-20の場合、範囲は1983〜2003になります。??? 誰かが抜け道を見つけましたか?

フィールドが空の場合、DatePickerは表示されないため、新しいレコードの作成中には表示されません。 これを解決するために、 ???textを使用して日付入力フィールド(現在は入力として表示されます)にデフォルト値を設定してみました。$this->setDefault('date_of_birth',date('Y-m-d'));ピッカーのこの問題に直面している人は、新しいレコードの作成中に利用できるようになりましたか???? また、デフォルト値を設定する正しい方法ですか?

前もって感謝します。

4

1 に答える 1

0

新しい登録フォームで日付ピッカーを取得するにinclude javascriptsは、フォームの indexSuccess テンプレートを使用する必要がありました (私のせいです)。

年の範囲については、プラグイン ファイルを変更して追加のパラメーターを含めました。

class sfWidgetFormDateJQueryUI extends sfWidgetForm
{
  protected function configure($options = array(), $attributes = array())
  {

    if(sfContext::hasInstance())
     $this->addOption('culture', sfContext::getInstance()->getUser()->getCulture());
    else
     $this->addOption('culture', "en");
    $this->addOption('change_month',  false);
    $this->addOption('change_year',  false);
    $this->addOption('number_of_months', 1);
    $this->addOption('show_button_panel',  false);
    $this->addOption('theme', '/sfJQueryUIPlugin/css/ui-lightness/jquery-ui.css');
    $this->addOption('year_range', '-30:+0');
    parent::configure($options, $attributes);
  }

  public function render($name, $value = null, $attributes = array(), $errors = array())
  {
    $attributes = $this->getAttributes();

    $input = new sfWidgetFormInput(array(), $attributes);

    $html = $input->render($name, $value);

    $id = $input->generateId($name);
    $culture = $this->getOption('culture');
    $cm = $this->getOption("change_month") ? "true" : "false";
    $cy = $this->getOption("change_year") ? "true" : "false";
    $nom = $this->getOption("number_of_months");
    $sbp = $this->getOption("show_button_panel") ? "true" : "false";
    $yrs = $this->getOption("year_range");

    if ($culture!='en')
    {
    $html .= <<<EOHTML
<script type="text/javascript">
    $(function() {
    var params = $.datepicker.regional['$culture'];
    params.changeMonth = $cm;
    params.changeYear = $cy;
    params.numberOfMonths = $nom;
    params.showButtonPanel = $sbp;
    params.yearRange = "$yrs";
    $("#$id").datepicker(params);
    });
</script>
EOHTML;
    }
    else
    {
    $html .= <<<EOHTML
<script type="text/javascript">
    $(function() {
    var params = {
    changeMonth : $cm,
    changeYear : $cy,
    numberOfMonths : $nom,
    showButtonPanel : $sbp,
    yearRange : "$yrs"
        };
    $("#$id").datepicker(params);
    });
</script>
EOHTML;
    }

    return $html;
  }

  public function getStylesheets()
  {...
  }

  public function getJavaScripts()
  {...
  }

}

ウィジェットを次のように設定します。

$this->widgetSchema['date_of_birth']= new sfWidgetFormDateJQueryUI(array("change_month" => true, "change_year" => true, "theme" => "smoothness/jquery-ui-1.8.custom.css", "year_range" => "-30:+0"));
于 2010-04-22T04:24:03.197 に答える