コード例 #1
0
 public function setValue($value)
 {
     if (is_string($value) && preg_match('/^\\d{4}$/', $value)) {
         $value = array('m' => (int) substr($value, 0, 2), 'y' => '20' . substr($value, 2, 2));
     }
     return parent::setValue($value);
 }
コード例 #2
0
 /**
  * Sets the element's value
  *
  * This also creates missing selects and loads their options, in addition
  * to {@link HTML_QuickForm2_Container_Group::setValue()} behaviour
  *
  * @param array $value
  *
  * @return $this
  */
 public function setValue($value)
 {
     $this->size = max($this->size, count($value));
     $this->_createSelects();
     parent::setValue($value);
     $this->_loadChildOptions();
     return $this;
 }
コード例 #3
0
ファイル: Date.php プロジェクト: restiaka/Guinn-App-Gen
 /**
  * Tries to convert the given value to a usable date before setting the
  * element value
  * @param    int|string|array    A timestamp, a string compatible with strtotime()
  *                               or an array that fits the element names
  */
 public function setValue($value)
 {
     if (empty($value)) {
         $value = array();
     } elseif (is_scalar($value)) {
         if (!is_numeric($value)) {
             $value = strtotime($value);
         }
         // might be a unix epoch, then we fill all possible values
         $arr = explode('-', date('w-j-n-Y-g-G-i-s-a-A-W', (int) $value));
         $value = array('D' => $arr[0], 'l' => $arr[0], 'd' => $arr[1], 'M' => $arr[2], 'm' => $arr[2], 'F' => $arr[2], 'Y' => $arr[3], 'y' => $arr[3], 'h' => $arr[4], 'g' => $arr[4], 'H' => $arr[5], 'i' => $this->trimLeadingZeros($arr[6]), 's' => $this->trimLeadingZeros($arr[7]), 'a' => $arr[8], 'A' => $arr[9], 'W' => $this->trimLeadingZeros($arr[10]));
     } else {
         $value = array_map(array($this, 'trimLeadingZeros'), $value);
     }
     return parent::setValue($value);
 }
コード例 #4
0
 public function testSetValueUpdatesAllElements()
 {
     $group = new HTML_QuickForm2_Container_Group();
     $foo = $group->addText('foo')->setValue('foo value');
     $bar = $group->addText('bar')->setValue('bar value');
     $group->setValue(array('foo' => 'new foo value'));
     $this->assertEquals('new foo value', $foo->getValue());
     $this->assertEquals('', $bar->getValue());
     $group->setValue(null);
     $this->assertEquals('', $foo->getValue());
     $this->assertEquals('', $bar->getValue());
 }