Skip to content
Snippets Groups Projects
Commit 1cd2bb67 authored by Satish's avatar Satish
Browse files

Fixes #511 - Percentage field 0.000 default value

parent 98b85388
No related branches found
No related tags found
1 merge request!188Fixes #510, #511
{*<!--
/*********************************************************************************
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*
********************************************************************************/
-->*}
{*+**********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*************************************************************************************}
{strip}
{assign var="FIELD_INFO" value=$FIELD_MODEL->getFieldInfo()}
{assign var="SPECIAL_VALIDATOR" value=$FIELD_MODEL->getValidator()}
{if (!$FIELD_NAME)}
{assign var="FIELD_NAME" value=$FIELD_MODEL->getFieldName()}
{/if}
<div class="input-group inputElement">
<input id="{$MODULE}_editView_fieldName_{$FIELD_NAME}" type="text" class="form-control" name="{$FIELD_NAME}"
value="{$FIELD_MODEL->get('fieldvalue')}" {if !empty($SPECIAL_VALIDATOR)}data-validator='{Zend_Json::encode($SPECIAL_VALIDATOR)}'{/if} step="any"
{if $FIELD_INFO["mandatory"] eq true} data-rule-required="true" {/if}
{if count($FIELD_INFO['validator'])}
data-specific-rules='{ZEND_JSON::encode($FIELD_INFO["validator"])}'
{/if}
/>
<span class="input-group-addon">%</span>
</div>
{assign var="FIELD_INFO" value=$FIELD_MODEL->getFieldInfo()}
{assign var="SPECIAL_VALIDATOR" value=$FIELD_MODEL->getValidator()}
{if (!$FIELD_NAME)}
{assign var="FIELD_NAME" value=$FIELD_MODEL->getFieldName()}
{/if}
{assign var="FIELD_VALUE" value=$FIELD_MODEL->get('fieldvalue')}
<div class="input-group inputElement">
<input id="{$MODULE}_editView_fieldName_{$FIELD_NAME}" type="text" class="form-control" data-field-id="{$FIELD_MODEL->get('id')}" name="{$FIELD_NAME}"
value="{if !empty($FIELD_VALUE) or $FIELD_VALUE neq NULL}{$FIELD_MODEL->getEditViewDisplayValue($FIELD_VALUE)}{/if}" {if !empty($SPECIAL_VALIDATOR)}data-validator="{Zend_Json::encode($SPECIAL_VALIDATOR)}"{/if} step="any"
{if $FIELD_INFO["mandatory"] eq true} data-rule-required="true" {/if}
{if count($FIELD_INFO['validator'])}
data-specific-rules="{ZEND_JSON::encode($FIELD_INFO["validator"])}"
{/if}
/>
<span class="input-group-addon">%</span>
</div>
{/strip}
......@@ -18,4 +18,13 @@ class Vtiger_Percentage_UIType extends Vtiger_Base_UIType {
return 'uitypes/Percentage.tpl';
}
}
\ No newline at end of file
public function getDisplayValue($value, $record = false, $recordInstance = false) {
$fldvalue = str_replace(",", ".", $value);
$value = (is_numeric($fldvalue)) ? $fldvalue : null;
return CurrencyField::convertToUserFormat($value, null, true);
}
public function getEditViewDisplayValue($value) {
return $this->getDisplayValue($value);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment