109 lines
2.5 KiB
PHP
109 lines
2.5 KiB
PHP
<?php
|
||
|
||
namespace Trinity\Bundle\ContentManagerBundle\Form\Type;
|
||
|
||
use Symfony\Component\Form\FormBuilderInterface;
|
||
|
||
class NodeAddType extends NodeType
|
||
{
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||
{
|
||
$builder->add(
|
||
'title',
|
||
'text'
|
||
);
|
||
|
||
$builder->add(
|
||
'position',
|
||
'hidden',
|
||
array(
|
||
'mapped' => false,
|
||
'data' => 'after',
|
||
)
|
||
);
|
||
|
||
$builder->add(
|
||
'pageContentType',
|
||
'choice',
|
||
array(
|
||
'mapped' => false,
|
||
'choices' => self::getPageContentTypes(),
|
||
'required' => false,
|
||
)
|
||
);
|
||
|
||
$builder->add(
|
||
'pageModel',
|
||
'choice',
|
||
array(
|
||
'mapped' => false,
|
||
'choices' => $this->getPagesModels(),
|
||
'required' => true,
|
||
)
|
||
);
|
||
|
||
$builder->add(
|
||
'page',
|
||
'model',
|
||
array(
|
||
'class' => 'Trinity\Bundle\ContentManagerBundle\Model\Page',
|
||
'query' => \Trinity\Bundle\ContentManagerBundle\Model\PageQuery::getOrphansQuery(),
|
||
'required' => false,
|
||
)
|
||
);
|
||
|
||
$builder->add(
|
||
'nodeAliasId',
|
||
'choice',
|
||
array(
|
||
'choices' => \Trinity\Bundle\ContentManagerBundle\Model\MenuPeer::getMenuWithNodesForType(),
|
||
'required' => true,
|
||
)
|
||
);
|
||
|
||
$builder->add(
|
||
'url',
|
||
'text',
|
||
array(
|
||
'required' => false,
|
||
'attr' => array(
|
||
'placeholder' => 'https://',
|
||
),
|
||
)
|
||
);
|
||
}
|
||
|
||
public static function getPositions()
|
||
{
|
||
return array(
|
||
'above' => 'Above',
|
||
'after' => 'After',
|
||
'before' => 'Before',
|
||
);
|
||
}
|
||
|
||
public static function getPageContentTypes()
|
||
{
|
||
return array(
|
||
'newpage' => 'New page',
|
||
'page' => 'Page',
|
||
'alias' => 'Alias',
|
||
'url' => 'URL',
|
||
'nopage' => 'No page',
|
||
);
|
||
}
|
||
|
||
public static function validatorPageContentTypes()
|
||
{
|
||
return array_keys(self::getPageContentTypes());
|
||
}
|
||
|
||
public static function validatorPositions()
|
||
{
|
||
return array_keys(self::getPositions());
|
||
}
|
||
}
|