Form/Type/CurrencyType.php
<?php
/**
* @author Rafał Muszyński <rafal.muszynski@sourcefabric.org>
* @copyright 2015 Sourcefabric z.ú.
* @license http://www.gnu.org/licenses/gpl-3.0.txt
*/
namespace Newscoop\PaywallBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Currency form type.
*/
class CurrencyType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('code', 'currency', array(
'label' => 'paywall.label.code',
'required' => true,
'constraints' => array(
new Assert\NotBlank(),
),
))
->add('isActive', 'checkbox', array(
'label' => 'paywall.label.isactive',
'required' => false,
))
->add('exchangeRate', 'number', array(
'label' => 'paywall.label.exchangerate',
'precision' => 5,
'constraints' => array(
new Assert\NotBlank(),
new Assert\Type(array('type' => 'numeric')),
new Assert\Range(array(
'min' => '0.00001',
'max' => '99999.99999',
)),
),
));
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'paywall_currency';
}
}