Permalink
Fetching contributors…
Cannot retrieve contributors at this time
61 lines (53 sloc) 1.56 KB
<?php
namespace Leapt\CoreBundle\Datalist\Field\Type;
use Leapt\CoreBundle\Datalist\Field\DatalistFieldInterface;
use Leapt\CoreBundle\Datalist\ViewContext;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* Class BooleanFieldType
* @package Leapt\CoreBundle\Datalist\Field\Type
*/
class BooleanFieldType extends AbstractFieldType
{
/**
* @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
$resolver
->setDefaults([
'true_label' => null,
'false_label' => null,
])
->setAllowedTypes('true_label', ['null', 'string'])
->setAllowedTypes('false_label', ['null', 'string'])
;
}
/**
* @param \Leapt\CoreBundle\Datalist\ViewContext $viewContext
* @param \Leapt\CoreBundle\Datalist\Field\DatalistFieldInterface $field
* @param mixed $row
* @param array $options
*/
public function buildViewContext(ViewContext $viewContext, DatalistFieldInterface $field, $row, array $options)
{
parent::buildViewContext($viewContext, $field, $row, $options);
$viewContext['true_label'] = $options['true_label'];
$viewContext['false_label'] = $options['false_label'];
}
/**
* @return string
*/
public function getName()
{
return 'boolean';
}
/**
* @return string
*/
public function getBlockName()
{
return 'boolean';
}
}