sfJQueryUIPlugin: ไม่มีตัวเลือกสำหรับบันทึกใหม่

ทุกวันเป็นวันใหม่ด้วย Symfony แต่ฉันชอบมันมาก! เมื่อเช้านี้ฉันติดตั้ง sfJQueryUIPlugin มีการขึ้นต่อกันน้อยมากและยอมรับสไตล์ของ themeRoller อย่างไรก็ตาม มันมี 2 ประเด็น:

[Feature_Request] ไม่มีวิธีระบุช่วงปี ตามค่าเริ่มต้น จะแสดงช่วง 20 ปีต่อปีในค่าฟิลด์ เช่น. ถ้าค่าฟิลด์เป็น 1993-01-20 ช่วงจะเป็น 1983 ถึง 2003 ??? มีใครพบทางออกบ้างไหม???

DatePicker ไม่ปรากฏขึ้นเมื่อฟิลด์ว่างเปล่า ดังนั้นจึงไม่ปรากฏขึ้นในระหว่างการสร้างเรกคอร์ดใหม่ เพื่อแก้ไขปัญหานี้ ฉันลองตั้งค่าเริ่มต้นในช่องป้อนวันที่ (ซึ่งตอนนี้ปรากฏเป็นอินพุต text) โดยใช้ $this->setDefault('date_of_birth',date('Y-m-d')); ??? มีใครประสบปัญหานี้ของตัวเลือกที่พร้อมใช้งานในระหว่างการสร้างบันทึกใหม่หรือไม่ ??? ??? เป็นวิธีการตั้งค่าเริ่มต้นที่ถูกต้องหรือไม่ ???

ขอบคุณล่วงหน้า.


person Prasad    schedule 21.04.2010    source แหล่งที่มา
comment
ฉันได้บันทึกคำขอคุณลักษณะและข้อบกพร่องแล้ว แค่อยากรู้ว่ามีคนอื่นประสบปัญหานี้หรือไม่? และพบทางแก้ไขแล้วหรือยัง?   -  person Prasad    schedule 21.04.2010


คำตอบ (1)


ในการรับตัวเลือกวันที่ในแบบฟอร์มการลงทะเบียนใหม่ ฉันต้อง 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"));
person Prasad    schedule 22.04.2010