示例#1
0
文件: fields.php 项目: uwitec/mgoa
 private static function set_extra_property(array $property, $data)
 {
     self::$extra = '';
     $data_exists = false;
     if ($data && $data != $property['value']) {
         $property['value'] = $data;
         $data_exists = true;
     }
     /*
      * Ignore the textarea, editor
      */
     $value_skip = array('editor', 'textarea');
     foreach ($property as $key => $value) {
         if (!in_array($key, self::$enable_property) || $key == 'value' && in_array($property['type'], $value_skip)) {
             continue;
         }
         if ($key == 'value' && !$data_exists) {
             $other = sprintf(' placeholder="%s" ', $value, $value, $value);
             self::$extra .= $other;
         } else {
             self::$extra .= sprintf(' %s="%s" %s', $key, $value, $other);
         }
     }
     if (!isset($property['require']) || $property['require']) {
         self::$extra .= 'required="true"';
     }
 }
示例#2
0
文件: forms.php 项目: uwitec/mgoa
 public function output()
 {
     import('system/share/web/forms/fields');
     $fields_html = array();
     foreach ($this->fields as $field_name => $property) {
         $fields_html['content'][$field_name] = BaseFields::get($field_name, $property, $this->data);
         $label = $this->fields[$field_name]['label'] ? $this->fields[$field_name]['label'] : $field_name;
         $fields_html['label'][$field_name] = _($label);
     }
     $fields_html['fields'] = $this->fields;
     if ($this->is_bound) {
         $fields_html['messages'] = $this->messages;
         $fields_html['data'] = $this->data;
     }
     return $fields_html;
 }
示例#3
0
 /**
  * Returns a peer instance associated with this om.
  *
  * Since Peer classes are not to have any instance attributes, this method returns the
  * same instance for all member of this class. The method could therefore
  * be static, but this would prevent one from overriding the behavior.
  *
  * @return     FieldsPeer
  */
 public function getPeer()
 {
     if (self::$peer === null) {
         self::$peer = new FieldsPeer();
     }
     return self::$peer;
 }