Laravel-admin: 希望为Form的 currency 方法增加 digits($number) 方法,以便指定小数点位数。

Created on 3 Jan 2017  ·  2Comments  ·  Source: z-song/laravel-admin

希望为Form的 currency 方法增加 digits($number) 方法,以便指定小数点位数。

    protected $digits = 2;

    public function digits($number)
    {
        $this->digits = (int)$number;

        return $this;
    }

    public function render()
    {
        $this->script = <<<EOT

$('.{$this->getElementClass()}').inputmask("currency", {radixPoint: '.', prefix:'', digits:$this->digits, removeMaskOnSubmit: true})

EOT;

        return parent::render()->with(['symbol' => $this->symbol]);
    }

Most helpful comment

现在可以用options方法实现添加option:

$form->curreny('money')->options(['digits' => 2]);

All 2 comments

现在可以用options方法实现添加option:

$form->curreny('money')->options(['digits' => 2]);

3 年后的今天,文档里竟然还没有这个介绍...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

donglianyou picture donglianyou  ·  3Comments

joernroeder picture joernroeder  ·  3Comments

fokoz picture fokoz  ·  3Comments

zhenyangze picture zhenyangze  ·  3Comments

chenyongmin picture chenyongmin  ·  3Comments