HTML_INPUT improve and test
This commit is contained in:
parent
22e1ac61fb
commit
ca4632fb93
3 changed files with 124 additions and 13 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -48,3 +48,5 @@ local/*
|
|||
include/tfpdf/font/unifont/*
|
||||
html/ads.html
|
||||
doc/code/*
|
||||
nbproject/private/
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ class IText extends HtmlInput
|
|||
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 +44,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
|
||||
|
|
@ -62,11 +65,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>
|
||||
style="width:%s;" %s %s %s %s %s %s %s>
|
||||
',$this->style,
|
||||
$this->id,
|
||||
$this->name,
|
||||
|
|
@ -78,7 +94,9 @@ 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"
|
||||
|
|
@ -94,7 +112,9 @@ class IText extends HtmlInput
|
|||
$this->extra,
|
||||
$autofocus,
|
||||
$require,
|
||||
$strAttribute
|
||||
$strAttribute,
|
||||
$pattern,
|
||||
$maxlength
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +130,8 @@ 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");
|
||||
$this->style=' class="input_text_ro" ';
|
||||
|
|
@ -119,16 +140,18 @@ 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 */
|
||||
if ( $this->table == 1 ) $r='<td>'.$r.'</td>';
|
||||
if ($this->table == 1) {
|
||||
$r = '<td>' . $r . '</td>';
|
||||
}
|
||||
|
||||
return $r;
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ $http=new HttpInput();
|
|||
|
||||
|
||||
<?php
|
||||
for ($i = 0 ; $i < 10 ; $i ++) :
|
||||
for ($i = 0 ; $i < 10 ; $i++ ) :
|
||||
echo '<li>';
|
||||
$check[$i]=new InputCheckBox("check[]",1,"checkid".$i);
|
||||
$check[$i]->classrange="improvechkbox";
|
||||
|
|
@ -133,11 +133,11 @@ $http=new HttpInput();
|
|||
console.debug("afile");
|
||||
console.debug(aFile);
|
||||
var info=document.getElementById("file-info");
|
||||
for (var i = 0;i < aFile.length;i++) {
|
||||
for (var i = 0;i < aFile.length;i) {
|
||||
if ( aFile[i].getAttribute("type")==="file" ) {
|
||||
|
||||
console.debug("file"+aFile[i].files[0].size);
|
||||
info.innerHTML+="file : "+aFile[i].files[0].name+":"+aFile[i].files[0].size+" bytes <br>";
|
||||
console.debug("file"aFile[i].files[0].size);
|
||||
info.innerHTML="file : "aFile[i].files[0].name":"aFile[i].files[0].size" bytes <br>";
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ $http=new HttpInput();
|
|||
document.getElementById("file_to_upload").addEventListener("change",function() {
|
||||
|
||||
if ( this.files[0] ) {
|
||||
console.debug("file"+this.files[0].size);
|
||||
console.debug("file"this.files[0].size);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
@ -159,5 +159,91 @@ $http=new HttpInput();
|
|||
?>
|
||||
|
||||
<div id="debug_box"></div>
|
||||
<h2>itext </h2>
|
||||
<h3>HTML Attribute</h3>
|
||||
<pre>
|
||||
$itext=new IText("itext_name");
|
||||
$itext->set_attribute("key1",1);
|
||||
$itext->set_attribute("data1","-data-");
|
||||
$itext->set_attribute("logx","data:logx");
|
||||
echo $itext->input();
|
||||
echo $itext->display();
|
||||
</pre>
|
||||
<?php
|
||||
$itext=new IText("itext_name");
|
||||
$itext->style=' class="input_text" ';
|
||||
$itext->set_attribute("key1",1);
|
||||
$itext->set_attribute("data1","-data-");
|
||||
$itext->set_attribute("logx","data:logx");
|
||||
echo $itext->input();
|
||||
echo $itext->display();
|
||||
?>
|
||||
<pre>
|
||||
<?= htmlspecialchars($itext->input());?>
|
||||
<?= htmlspecialchars($itext->display());?>
|
||||
</pre>
|
||||
<h3>Maxlenght = 15</h3>
|
||||
<?php
|
||||
$itext->maxlength=15;
|
||||
$itext->style=' class="input_text" ';
|
||||
echo $itext->input();
|
||||
echo $itext->display();
|
||||
?>
|
||||
<pre>
|
||||
<?= htmlspecialchars($itext->input());?>
|
||||
<?= htmlspecialchars($itext->display());?>
|
||||
</pre>
|
||||
<h3>placeholder</h3>
|
||||
<?php
|
||||
$itext->style=' class="input_text" ';
|
||||
$itext->placeholder="Donnez une information";
|
||||
echo $itext->input();
|
||||
echo $itext->display();
|
||||
?>
|
||||
<pre>
|
||||
$itext->placeholder="Donnez une information";
|
||||
<?= htmlspecialchars($itext->input());?>
|
||||
<?= htmlspecialchars($itext->display());?>
|
||||
</pre>
|
||||
<h3>require</h3>
|
||||
<?php
|
||||
$itext->style=' class="input_text" ';
|
||||
$itext->require=true;
|
||||
echo $itext->input();
|
||||
echo $itext->display();
|
||||
?>
|
||||
<pre>
|
||||
$itext->require=true;
|
||||
<?= htmlspecialchars($itext->input());?>
|
||||
<?= htmlspecialchars($itext->display());?>
|
||||
</pre>
|
||||
|
||||
<h3>pattern : uniquement des chiffres</h3>
|
||||
<form onsubmit="return false;">
|
||||
|
||||
<?php
|
||||
$itext->style=' class="input_text" ';
|
||||
$itext->pattern="[0-9]";
|
||||
$itext->maxlength="4";
|
||||
$itext->placeholder="9999";
|
||||
$itext->title="code";
|
||||
echo $itext->input();
|
||||
echo $itext->display();
|
||||
echo HtmlInput::submit("valider","valider");
|
||||
?>
|
||||
<pre>
|
||||
$itext->pattern="[0-9]";
|
||||
<?= htmlspecialchars($itext->input());?>
|
||||
<?= htmlspecialchars($itext->display());?>
|
||||
</pre>
|
||||
</form>
|
||||
<h2> IDATE</h2>
|
||||
<?php
|
||||
$date=new IDate('date_1',date("d.m.Y"));
|
||||
echo $date->input();
|
||||
echo htmlspecialchars($date->input());
|
||||
$date->id= uniqid();
|
||||
$date->javascript=sprintf('onchange = "console.debug(\'change date\');%s"',"format_date(this);");
|
||||
echo $date->input();
|
||||
?>
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue