New Field Type

New Field Type

by Stuart Watson -
Number of replies: 2

Hi

I want to define a new field type, identical to the text field but simply smaller in text size, height and width.

Can anyone help me with this?

Here's what I have so far in field.class.php.  The input side works fine, but I can't get it to display in view single or view list.  My OOP is fairly limited and I'm struggling to get any further.

 

class data_field_smalltext extends data_field_base {

    var $type = 'smalltext';

    function data_field_smalltext($field=0, $data=0) {
        parent::data_field_base($field, $data);
    }
   
    function display_add_field($recordid=0){
  $str = '<input style="width:200px; height:10px; font-size:10px" type="text">';
  return $str;
 }

  
 function display_search_field($value = '') {
        return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';  
    }
   
    function parse_search_field() {
        return optional_param('f_'.$this->field->id, '', PARAM_NOTAGS);
    }
   
    function generate_sql($tablealias, $value) {
        return " ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content LIKE '%{$value}%') ";
    }
   
}

Cheers Stu

Average of ratings: -
In reply to Stuart Watson

Re: New Field Type

by Itamar Tzadok -

IMO, instead adding a new field type we can add to the current text type either a width option or a class name option or both. This would allow users to determine the width of a particular field either directly or by a css definition. This should be an easy patch.

Since it may be of interest to many why not open a tracker issue and we'll take it from there?

smile