Skip to content

Commit

Permalink
fix: display value for Rupiah
Browse files Browse the repository at this point in the history
  • Loading branch information
uyab committed Jan 20, 2020
1 parent 10a492d commit d0aee93
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/Elements/Rupiah.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php namespace Laravolt\SemanticForm\Elements;

class Rupiah extends InputWrapper
{
public function __construct($input)
{
parent::__construct($input);

$this->prependLabel('Rp');
$this->getPrimaryControl()->data('role', 'rupiah');
}

public function displayValue()
{
return 'Rp' . number_format($this->getPrimaryControl()->displayValue(), 0, ',', '.');
}
}
7 changes: 5 additions & 2 deletions src/SemanticForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Laravolt\SemanticForm\Elements\Number;
use Laravolt\SemanticForm\Elements\RadioGroup;
use Laravolt\SemanticForm\Elements\Redactor;
use Laravolt\SemanticForm\Elements\Rupiah;
use Laravolt\SemanticForm\Elements\SelectDateWrapper;
use Laravolt\SemanticForm\Elements\SelectDateTimeWrapper;
use Laravolt\SemanticForm\Elements\SelectMultiple;
Expand Down Expand Up @@ -508,8 +509,10 @@ public function rupiah($name, $defaultValue = null)
{
\Stolz\Assets\Laravel\Facade::group('laravolt')->add('autoNumeric');

$input = $this->input($name, $defaultValue)->prependLabel('Rp');
$input->getPrimaryControl()->data('role', 'rupiah');
$text = $this->text($name, $defaultValue);
// $input = $this->input($name, $defaultValue)->prependLabel('Rp');
// $input->getPrimaryControl()->data('role', 'rupiah');
$input = (new Rupiah($text));

return $input;
}
Expand Down

0 comments on commit d0aee93

Please sign in to comment.