Example #1
0
 /**
  * Returns form field type associated with model field.
  *
  * Redefine this method to add special handling of your own fields.
  *
  * @param Field $field
  *
  * @return string
  */
 public function getFieldType($field)
 {
     // default form field type
     $type = 'Line';
     // try to find associated form field type
     if (isset($this->type_associations[$field->type()])) {
         $type = $this->type_associations[$field->type()];
     }
     if ($field instanceof Field_Reference) {
         $type = 'DropDown';
     }
     // if form field type explicitly set in model
     if ($field->display()) {
         $tmp = $field->display();
         if (is_array($tmp)) {
             $tmp = $tmp['form'];
         }
         if ($tmp) {
             $type = $tmp;
         }
     }
     return $type;
 }
Example #2
0
 /**
  * Returns grid column type associated with model field.
  *
  * Redefine this method to add special handling of your own fields.
  *
  * @param Field $field
  *
  * @return string
  */
 public function getFieldType($field)
 {
     // default column type
     $type = $field->type();
     // try to find associated form field type
     if (isset($this->type_associations[$type])) {
         $type = $this->type_associations[$type];
     }
     if ($type == 'text' && $field->allowHtml()) {
         $type = 'html';
     }
     // if grid column type/formatter explicitly set in model
     if ($field->display()) {
         // @todo this is wrong and obsolete, as hasOne uses display for way different purpose
         $tmp = $field->display();
         if (is_array($tmp)) {
             $tmp = $tmp['grid'];
         }
         if ($tmp) {
             $type = $tmp;
         }
     }
     return $type;
 }