Improve Input_Switch , do not echo but returns string
This commit is contained in:
parent
1b041e65de
commit
30688bda9d
3 changed files with 13 additions and 12 deletions
|
|
@ -45,6 +45,7 @@ class InputSwitch extends HtmlInput
|
|||
|
||||
function input($p_name=NULL, $p_value=NULL)
|
||||
{
|
||||
$r="";
|
||||
if ($p_name!=NULL)
|
||||
$this->value_container=$p_name;
|
||||
if ($p_value!==NULL)
|
||||
|
|
@ -56,25 +57,25 @@ class InputSwitch extends HtmlInput
|
|||
throw new Exception(_("Valeur invalide"),1);
|
||||
}
|
||||
if ($this->readOnly == TRUE) {
|
||||
$this->display();
|
||||
return;
|
||||
return $this->display();
|
||||
}
|
||||
echo HtmlInput::hidden($this->value_container, $this->value);
|
||||
$r.= HtmlInput::hidden($this->value_container, $this->value);
|
||||
|
||||
$this->javascript=sprintf('toggle_onoff(\'%s\',\'%s\');%s;',$this->icon,$this->value_container,$this->javascript);
|
||||
|
||||
if ($this->value=='1') {
|
||||
echo Icon_Action::iconon($this->icon, $this->javascript);
|
||||
$r.=Icon_Action::iconon($this->icon, $this->javascript);
|
||||
} else {
|
||||
echo Icon_Action::iconoff($this->icon, $this->javascript);
|
||||
$r.=Icon_Action::iconoff($this->icon, $this->javascript);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
function display()
|
||||
{
|
||||
if ($this->value=='1') {
|
||||
echo Icon_Action::iconon($this->icon, "");
|
||||
return Icon_Action::iconon($this->icon, "");
|
||||
} else {
|
||||
echo Icon_Action::iconoff($this->icon, "");
|
||||
return Icon_Action::iconoff($this->icon, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ if ( $type == 'ACH' || $type == 'VEN'||$new):
|
|||
<td>
|
||||
<?php
|
||||
$negative->javascript="toggle_row_warning_enable('negative_amount','row_warning')";
|
||||
$negative->input();
|
||||
echo $negative->input();
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -61,25 +61,25 @@ $http=new HttpInput();
|
|||
<pre>
|
||||
|
||||
$input_switch=new InputSwitch('input_switch_value',<?php echo $http->get("input_switch_value","string","0")?>);
|
||||
$input_switch->input();
|
||||
echo $input_switch->input();
|
||||
</pre>
|
||||
input_switch
|
||||
<?php
|
||||
|
||||
$input_switch=new InputSwitch('input_switch_value',$http->get("input_switch_value","string","0"));
|
||||
$input_switch->input();
|
||||
echo $input_switch->input();
|
||||
?>
|
||||
<h2>ReadOnly</h2>
|
||||
<pre>
|
||||
$input_switch=new InputSwitch('input_switch_readonly',0);
|
||||
$input_switch->readOnly=TRUE;
|
||||
$input_switch->input();
|
||||
echo $input_switch->input();
|
||||
</pre>
|
||||
input_switch
|
||||
<?php
|
||||
$input_switch=new InputSwitch('input_switch_readonly',0);
|
||||
$input_switch->readOnly=TRUE;
|
||||
$input_switch->input();
|
||||
echo $input_switch->input();
|
||||
?>
|
||||
<h1>Submit</h1>
|
||||
<pre>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue