HTML_INPUT improve and test
This commit is contained in:
parent
83670cecb8
commit
9c6aa2dee7
6 changed files with 145 additions and 33 deletions
|
|
@ -76,6 +76,7 @@ class HtmlInput
|
|||
var $id;
|
||||
var $style;
|
||||
var $css_size;
|
||||
var $placeholder; /*< $placeholder string in the INPUT Text */
|
||||
|
||||
function __construct($p_name="", $p_value="", $p_id="")
|
||||
{
|
||||
|
|
@ -100,9 +101,26 @@ class HtmlInput
|
|||
{
|
||||
$this->readOnly=$p_read;
|
||||
}
|
||||
/**
|
||||
* @return string HTML placeholder attribut
|
||||
*/
|
||||
public function get_placeholder()
|
||||
{
|
||||
return $this->placeholder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief set HTML placeholder attribut
|
||||
* @param string $placeholder
|
||||
*/
|
||||
public function set_placeholder($placeholder)
|
||||
{
|
||||
$this->placeholder = $placeholder;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief set the extra javascript property for the INPUT field
|
||||
* \brief add an HTML attribute for the INPUT field
|
||||
* \param $p_name name of the parameter
|
||||
* \param $p_value default value of this parameter
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -46,25 +46,9 @@ class IDate extends HtmlInput
|
|||
$this->extra="";
|
||||
$this->style=' class="input_text" ';
|
||||
$this->autofocus=false;
|
||||
$this->javascript='onchange="format_date(this)"';
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function get_placeholder()
|
||||
{
|
||||
return $this->placeholder;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $placeholder
|
||||
*/
|
||||
public function set_placeholder($placeholder)
|
||||
{
|
||||
$this->placeholder = $placeholder;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -131,7 +115,8 @@ class IDate extends HtmlInput
|
|||
return $this->display();
|
||||
if ($this->id=="") $this->id=self::generate_id($this->name);
|
||||
$autofocus=($this->autofocus)?" autofocus ":"";
|
||||
$onchange='onchange="format_date(this)"';
|
||||
$strAttribute=$this->get_node_attribute();
|
||||
|
||||
$r=sprintf('
|
||||
<input type="text" name="%s" id="%s"
|
||||
class="input_text"
|
||||
|
|
@ -141,6 +126,7 @@ class IDate extends HtmlInput
|
|||
title="%s"
|
||||
pattern="[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4}"
|
||||
%s
|
||||
%s
|
||||
/>
|
||||
<span class="smallbutton icon"
|
||||
style="color:cornflowerblue"
|
||||
|
|
@ -149,7 +135,8 @@ class IDate extends HtmlInput
|
|||

|
||||
</span>
|
||||
',$this->name,$this->id,$this->value,$this->placeholder,$this->title,
|
||||
$onchange,
|
||||
$this->javascript,
|
||||
$strAttribute,
|
||||
$this->id
|
||||
);
|
||||
// @see calendar-setup.js
|
||||
|
|
|
|||
|
|
@ -35,8 +35,9 @@ class IHidden extends HtmlInput
|
|||
$this->name=($p_name==null)?$this->name:$p_name;
|
||||
$this->value=($p_value==null)?$this->value:$p_value;
|
||||
$this->id=($this->id=="")?$this->name:$this->id;
|
||||
|
||||
$r='<INPUT TYPE="HIDDEN" id="'.$this->id.'" name="'.$this->name.'" value="'.$this->value.'">';
|
||||
$strAttribute=$this->get_node_attribute();
|
||||
|
||||
$r='<INPUT TYPE="HIDDEN" id="'.$this->id.'" name="'.$this->name.'" value="'.$this->value.'" '.$strAttribute.' >';
|
||||
return $r;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@
|
|||
*/
|
||||
class IText extends HtmlInput
|
||||
{
|
||||
var $placeholder;
|
||||
var $title;
|
||||
var $autofocus;
|
||||
var $css_size;
|
||||
|
||||
var $pattern; /*!< $pattern HTML pattern */
|
||||
var $maxlength; /*!< HTML maxlength */
|
||||
function __construct($name='',$value='',$p_id="")
|
||||
{
|
||||
parent::__construct($name,$value,$p_id);
|
||||
|
|
@ -43,6 +43,8 @@ class IText extends HtmlInput
|
|||
$this->autofocus=false;
|
||||
$this->require=false;
|
||||
$this->css_size="";
|
||||
$this->pattern="";
|
||||
$this->maxlength="";
|
||||
}
|
||||
/*!\brief show the html input of the widget*/
|
||||
public function input($p_name=null,$p_value=null)
|
||||
|
|
@ -60,11 +62,24 @@ class IText extends HtmlInput
|
|||
$t= 'title="'.$this->title.'" ';
|
||||
$autofocus=($this->autofocus)?" autofocus ":"";
|
||||
$require=($this->require)?"required":"";
|
||||
|
||||
// var $pattern regex to match the INPUT TEXT
|
||||
$pattern="";
|
||||
if ($this->pattern != "") {
|
||||
$pattern= sprintf( 'pattern="%s"',$this->pattern);
|
||||
}
|
||||
|
||||
// var maxlength HTML attribute
|
||||
$maxlength = "";
|
||||
if ($this->maxlength !="" ) {
|
||||
$maxlength=sprintf(' maxlength="%s" ',$this->maxlength);
|
||||
}
|
||||
|
||||
if ( ! isset ($this->css_size) || empty ($this->css_size))
|
||||
{
|
||||
|
||||
$r= sprintf('<INPUT TYPE="TEXT" %s id="%s" name="%s" value="%s" placeholder="%s" title="%s"
|
||||
Size="%s" %s %s %s %s %s>
|
||||
Size="%s" %s %s %s %s %s %s %s >
|
||||
',$this->style,
|
||||
$this->id,
|
||||
$this->name,
|
||||
|
|
@ -76,11 +91,13 @@ class IText extends HtmlInput
|
|||
$this->extra,
|
||||
$autofocus,
|
||||
$require,
|
||||
$strAttribute
|
||||
$strAttribute,
|
||||
$pattern,
|
||||
$maxlength
|
||||
);
|
||||
} else {
|
||||
$r= sprintf('<INPUT TYPE="TEXT" %s id="%s" name="%s" value="%s" placeholder="%s" title="%s"
|
||||
style="width:%s;" %s %s %s %s %s>
|
||||
style="width:%s;" %s %s %s %s %s %s %s>
|
||||
',$this->style,
|
||||
$this->id,
|
||||
$this->name,
|
||||
|
|
@ -92,7 +109,9 @@ class IText extends HtmlInput
|
|||
$this->extra,
|
||||
$autofocus,
|
||||
$require,
|
||||
$strAttribute
|
||||
$strAttribute,
|
||||
$pattern,
|
||||
$maxlength
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -108,6 +127,7 @@ class IText extends HtmlInput
|
|||
$t= ((isset($this->title)))?'title="'.$this->title.'" ':' ';
|
||||
|
||||
$extra=(isset($this->extra))?$this->extra:"";
|
||||
$strAttribute=$this->get_node_attribute();
|
||||
|
||||
$readonly=" readonly ";
|
||||
$this->value=htmlentities($this->value??"", ENT_COMPAT|ENT_QUOTES, "UTF-8");
|
||||
|
|
@ -117,12 +137,12 @@ class IText extends HtmlInput
|
|||
$r='<INPUT '.$this->style.' TYPE="TEXT" id="'.
|
||||
$this->id.'"'.$t.
|
||||
'NAME="'.$this->name.'" VALUE="'.$this->value.'" '.
|
||||
'SIZE="'.$this->size.'" '.$this->javascript." $readonly $this->extra >";
|
||||
'SIZE="'.$this->size.'" '.$this->javascript." $readonly $this->extra $strAttribute>";
|
||||
} else {
|
||||
$r='<INPUT '.$this->style.' TYPE="TEXT" id="'.
|
||||
$this->id.'"'.$t.
|
||||
'NAME="'.$this->name.'" VALUE="'.$this->value.'" '.
|
||||
' style="width:'.$this->css_size.'" '.$this->javascript." $readonly $this->extra >";
|
||||
' style="width:'.$this->css_size.'" '.$this->javascript." $readonly $this->extra $strAttribute>";
|
||||
}
|
||||
|
||||
/* add tag for column if inside a table */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue