Initial user ability to set foreign currency

This commit is contained in:
James Cole
2017-04-14 10:16:52 +02:00
parent b99bfcd02e
commit 9a69ce309e
16 changed files with 152 additions and 13 deletions

View File

@@ -261,6 +261,37 @@ class ExpandedForm
return $html;
}
/**
* @param string $name
* @param null $value
* @param array $options
*
* @return string
*/
public function nonSelectableAmount(string $name, $value = null, array $options = []): string
{
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
$classes = $this->getHolderClasses($name);
$value = $this->fillFieldValue($name, $value);
$options['step'] = 'any';
$options['min'] = '0.01';
$selectedCurrency = isset($options['currency']) ? $options['currency'] : Amt::getDefaultCurrency();
unset($options['currency']);
unset($options['placeholder']);
// make sure value is formatted nicely:
if (!is_null($value) && $value !== '') {
$value = round($value, $selectedCurrency->decimal_places);
}
$html = view('form.non-selectable-amount', compact('selectedCurrency', 'classes', 'name', 'label', 'value', 'options'))->render();
return $html;
}
/**
* @param string $name
* @param null $value
@@ -270,7 +301,6 @@ class ExpandedForm
*/
public function nonSelectableBalance(string $name, $value = null, array $options = []): string
{
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
$classes = $this->getHolderClasses($name);
@@ -286,7 +316,7 @@ class ExpandedForm
}
$html = view('form.non-selectable-balance', compact('selectedCurrency', 'classes', 'name', 'label', 'value', 'options'))->render();
$html = view('form.non-selectable-amount', compact('selectedCurrency', 'classes', 'name', 'label', 'value', 'options'))->render();
return $html;
}