Merge pull request #8653 from ATM-Marc/NEW_commonObject_array
NEW: work on CommonObject 'array' field typeNew common object array
This commit is contained in:
commit
659fd46b76
@ -5555,6 +5555,41 @@ abstract class CommonObject
|
|||||||
// If prefix is 'search_', field is used as a filter, we use a common text field.
|
// If prefix is 'search_', field is used as a filter, we use a common text field.
|
||||||
$out='<input type="'.($keyprefix=='search_'?'text':'password').'" class="flat '.$showsize.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
|
$out='<input type="'.($keyprefix=='search_'?'text':'password').'" class="flat '.$showsize.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
|
||||||
}
|
}
|
||||||
|
elseif ($type == 'array')
|
||||||
|
{
|
||||||
|
$newval = $val;
|
||||||
|
$newval['type'] = 'varchar(256)';
|
||||||
|
|
||||||
|
$out='';
|
||||||
|
|
||||||
|
$inputs = array();
|
||||||
|
if(! empty($value)) {
|
||||||
|
foreach($value as $option) {
|
||||||
|
$out.= '<span><a class="'.dol_escape_htmltag($keyprefix.$key.$keysuffix).'_del" href="javascript:;"><span class="fa fa-minus-circle valignmiddle"></span></a> ';
|
||||||
|
$out.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', $option, $moreparam, '', '', $showsize).'<br></span>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$out.= '<a id="'.dol_escape_htmltag($keyprefix.$key.$keysuffix).'_add" href="javascript:;"><span class="fa fa-plus-circle valignmiddle"></span></a>';
|
||||||
|
|
||||||
|
$newInput = '<span><a class="'.dol_escape_htmltag($keyprefix.$key.$keysuffix).'_del" href="javascript:;"><span class="fa fa-minus-circle valignmiddle"></span></a> ';
|
||||||
|
$newInput.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', '', $moreparam, '', '', $showsize).'<br></span>';
|
||||||
|
|
||||||
|
if(! empty($conf->use_javascript_ajax)) {
|
||||||
|
$out.= '
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
$("a#'.dol_escape_js($keyprefix.$key.$keysuffix).'_add").click(function() {
|
||||||
|
$("'.dol_escape_js($newInput).'").insertBefore(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on("click", "a.'.dol_escape_js($keyprefix.$key.$keysuffix).'_del", function() {
|
||||||
|
$(this).parent().remove();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>';
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!empty($hidden)) {
|
if (!empty($hidden)) {
|
||||||
$out='<input type="hidden" value="'.$value.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'"/>';
|
$out='<input type="hidden" value="'.$value.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'"/>';
|
||||||
}
|
}
|
||||||
@ -5926,6 +5961,10 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
$value=preg_replace('/./i','*',$value);
|
$value=preg_replace('/./i','*',$value);
|
||||||
}
|
}
|
||||||
|
elseif ($type == 'array')
|
||||||
|
{
|
||||||
|
$value = implode('<br>', $value);
|
||||||
|
}
|
||||||
|
|
||||||
//print $type.'-'.$size;
|
//print $type.'-'.$size;
|
||||||
$out=$value;
|
$out=$value;
|
||||||
@ -6614,7 +6653,14 @@ abstract class CommonObject
|
|||||||
}
|
}
|
||||||
else if($this->isArray($info))
|
else if($this->isArray($info))
|
||||||
{
|
{
|
||||||
$queryarray[$field] = serialize($this->{$field});
|
if(! empty($this->{$field})) {
|
||||||
|
if(! is_array($this->{$field})) {
|
||||||
|
$this->{$field} = array($this->{$field});
|
||||||
|
}
|
||||||
|
$queryarray[$field] = serialize($this->{$field});
|
||||||
|
} else {
|
||||||
|
$queryarray[$field] = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if($this->isInt($info))
|
else if($this->isInt($info))
|
||||||
{
|
{
|
||||||
@ -6658,9 +6704,13 @@ abstract class CommonObject
|
|||||||
}
|
}
|
||||||
elseif($this->isArray($info))
|
elseif($this->isArray($info))
|
||||||
{
|
{
|
||||||
$this->{$field} = @unserialize($obj->{$field});
|
if(! empty($obj->{$field})) {
|
||||||
// Hack for data not in UTF8
|
$this->{$field} = @unserialize($obj->{$field});
|
||||||
if($this->{$field } === false) @unserialize(utf8_decode($obj->{$field}));
|
// Hack for data not in UTF8
|
||||||
|
if($this->{$field } === false) @unserialize(utf8_decode($obj->{$field}));
|
||||||
|
} else {
|
||||||
|
$this->{$field} = array();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elseif($this->isInt($info))
|
elseif($this->isInt($info))
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user