public function __construct(ObjectManager $objectManager) { $this->setObjectManager($objectManager); parent::__construct(null); $this->setAttribute('method', 'POST'); $this->setAttribute('class', 'form-horizontal'); //Input Titulo $titulo = new Text('titulo'); $titulo->setLabel('Titulo')->setAttributes(array('maxlength' => 80)); $this->add($titulo); //Input Descrição $descricao = new Textarea('descricao'); $descricao->setLabel('descriçao')->setAttributes(array('maxlength' => 150)); $this->add($descricao); //Input Titulo $texto = new Textarea('texto'); $texto->setLabel('Texto'); $this->add($texto); $ativo = new Checkbox('ativo'); $ativo->setLabel('Ativo'); $this->add($ativo); $categoria = new ObjectSelect('category'); $categoria->setLabel('Categoria')->setOptions(array('object_manager' => $this->getObjectManager(), 'target_class' => '\\Base\\Orm\\Entities\\Category', 'property' => 'nome', 'empty_option' => '--Selecione--', 'is_method' => true, 'find_method' => array('name' => 'findBy', 'params' => array('criteria' => array(), 'orderBy' => array('nome' => 'ASC'))))); $this->add($categoria); //Botao submit $button = new Button('submit'); $button->setLabel('Salvar')->setAttributes(array('type' => 'submit', 'class' => 'btn')); $this->add($button); $this->setInputFilter(new PostFilter($categoria->getValueOptions())); }
public function __construct(ObjectManager $objectManager) { $this->setObjectManager($objectManager); parent::__construct(null); $this->setAttributes(array('method' => 'POST', 'accept-charset' => 'UTF-8', 'class' => 'form-horizontal')); //input Titulo $titulo = new Text('titulo'); $titulo->setLabel('Titulo')->setAttributes(array('id' => 'nome', 'maxlength' => 80, 'class' => 'form-control')); $this->add($titulo); //input descri��o $descricao = new Textarea('descricao'); $descricao->setLabel("Descricao")->setAttributes(array('id' => 'descricao', 'maxlength' => 150, 'class' => 'form-control')); $this->add($descricao); //input texto $texto = new Textarea('texto'); $texto->setLabel('Texto')->setAttributes(array('id' => 'texto', 'class' => 'form-control')); $this->add($texto); //input Ativo $ativo = new Checkbox('ativo'); $ativo->setLabel('Ativo')->setLabelAttributes(array('class' => 'checkbox-inline'))->setOptions(array('use_hidden_element' => true)); $this->add($ativo); //Categoria $categoria = new ObjectSelect('category'); $categoria->setLabel('Categoria')->setOptions(array('object_manager' => $this->getObjectManager(), 'target_class' => 'Categoria\\Entity\\Category', 'property' => 'nome', 'empty_option' => '--Selecione--', 'is_method' => true, 'find_method' => array('name' => 'findBy', 'params' => array('criteria' => array(), 'orderBy' => array('nome' => 'ASC')))))->setAttributes(array('id' => 'category', 'class' => 'form-control')); $this->add($categoria); //botao submit $button = new Button('submit'); $button->setLabel('Salvar')->setAttributes(array('type' => 'submit', 'class' => 'btn btn-default')); $this->add($button); $this->setInputFilter(new PostFilter($categoria->getValueOptions())); }
/** * {@inheritDoc} * * @return ObjectSelect */ public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $entityManager = $container->get('Doctrine\\ORM\\EntityManager'); $element = new ObjectSelect(); $element->getProxy()->setObjectManager($entityManager); return $element; }
/** * LancamentosForm constructor. * @param ObjectManager $objectManager */ public function __construct(ObjectManager $objectManager) { $this->setObjectManager($objectManager); parent::__construct(null); $this->setAttribute('method', 'POST'); $this->setAttribute('class', 'form-horizontal'); $prioridade = new ObjectSelect('prioridade'); $prioridade->setLabel('Prioridade')->setOptions(array('object_manager' => $this->getObjectManager(), 'target_class' => 'Prioridade\\Entity\\Prioridade', 'property' => 'name', 'empty_option' => '--Selecione--', 'is_method' => true, 'find_method' => array('name' => 'findBy', 'params' => array('criteria' => array(), 'orderBy' => array('name' => 'ASC')))))->setAttributes(array('class' => 'form-control')); $this->add($prioridade); $categoria = new ObjectSelect('categoria'); $categoria->setLabel('Categoria')->setOptions(array('object_manager' => $this->getObjectManager(), 'target_class' => 'Categoria\\Entity\\Categoria', 'property' => 'name', 'empty_option' => '--Selecione--', 'is_method' => true, 'find_method' => array('name' => 'findBy', 'params' => array('criteria' => array(), 'orderBy' => array('name' => 'ASC')))))->setAttributes(array('class' => 'form-control')); $this->add($categoria); $operacao = new ObjectSelect('operacao'); $operacao->setLabel('Operacoes')->setOptions(array('object_manager' => $this->getObjectManager(), 'target_class' => 'Operacoes\\Entity\\Operacoes', 'property' => 'name', 'empty_option' => '--Selecione--', 'is_method' => true, 'find_method' => array('name' => 'findBy', 'params' => array('criteria' => array(), 'orderBy' => array('name' => 'ASC')))))->setAttributes(array('class' => 'form-control')); $this->add($operacao); $origem = new ObjectSelect('origem'); $origem->setLabel('Origem')->setOptions(array('object_manager' => $this->getObjectManager(), 'target_class' => 'Origem\\Entity\\Origem', 'property' => 'name', 'empty_option' => '--Selecione--', 'is_method' => true, 'find_method' => array('name' => 'findBy', 'params' => array('criteria' => array(), 'orderBy' => array('name' => 'ASC')))))->setAttributes(array('class' => 'form-control')); $this->add($origem); //Input Saldo Inicial $valorInicial = new Text('valorInicial'); $valorInicial->setLabel('Valor Inicial')->setAttributes(array('maxlength' => 10, 'class' => 'form-control')); $this->add($valorInicial); //Input Saldo Inicial $valorFinal = new Text('valorFinal'); $valorFinal->setLabel('Valor Final')->setAttributes(array('maxlength' => 10, 'class' => 'form-control')); $this->add($valorFinal); $tipo = new ObjectSelect('tipo'); $tipo->setLabel('Tipo')->setOptions(array('object_manager' => $this->getObjectManager(), 'target_class' => 'Tipo\\Entity\\Tipo', 'property' => 'name', 'empty_option' => '--Selecione--', 'is_method' => true, 'find_method' => array('name' => 'findBy', 'params' => array('criteria' => array(), 'orderBy' => array('name' => 'ASC')))))->setAttributes(array('class' => 'form-control')); $this->add($tipo); //Botao submit $button = new Button('submit'); $button->setAttributes(array('type' => 'submit', 'class' => 'btn btn-success', 'value' => 'Salvar')); $this->add($button); $this->setInputFilter(new LancamentosFilter($categoria->getValueOptions(), $operacao->getValueOptions(), $origem->getValueOptions(), $tipo->getValueOptions(), $prioridade->getValueOptions())); }
public function __construct(ObjectManager $objectManager) { $this->setObjectManager($objectManager); parent::__construct(null); $this->setAttributes(array('method' => 'POST', 'accept-charset' => 'UTF-8', 'class' => 'form-horizontal')); //input Titulo $nome = new Text('nome'); $nome->setLabel('Nome')->setAttributes(array('id' => 'nome', 'maxlength' => 80, 'class' => 'form-control')); $this->add($nome); //input email $email = new Text('email'); $email->setLabel("email")->setAttributes(array('id' => 'email', 'maxlength' => 150, 'class' => 'form-control')); $this->add($email); //nivel_id $nivel = new ObjectSelect('nivel'); $nivel->setLabel('Nivel')->setOptions(array('object_manager' => $this->getObjectManager(), 'target_class' => 'Nivel\\Entity\\Nivel', 'property' => 'nome', 'empty_option' => '--Selecione--', 'is_method' => true, 'find_method' => array('name' => 'findBy', 'params' => array('criteria' => array(), 'orderBy' => array('nome' => 'ASC')))))->setAttributes(array('id' => 'nivel', 'class' => 'form-control')); $this->add($nivel); //login_id $login = new Text('login'); $login->setLabel('Login')->setAttributes(array('id' => 'login', 'maxlength' => 45, 'class' => 'form-control'))->setLabelAttributes(array()); $this->add($login); //botao submit $button = new Button('submit'); $button->setLabel('Salvar')->setAttributes(array('type' => 'submit', 'class' => 'btn btn-default')); $this->add($button); $this->setInputFilter(new UsuarioEditFilter($nivel->getValueOptions())); }
/** * {@inheritDoc} */ public function createService(ServiceLocatorInterface $pluginManager) { $services = $pluginManager->getServiceLocator(); $entityManager = $services->get('Doctrine\\ORM\\EntityManager'); $element = new ObjectSelect(); $element->getProxy()->setObjectManager($entityManager); return $element; }
public function testGetValueOptionsDoesntInvokeProxyIfOptionsNotEmpty() { $options = array('foo' => 'bar'); $proxy = $this->getMock('DoctrineModule\\Form\\Element\\Proxy'); $proxy->expects($this->once())->method('getValueOptions')->will($this->returnValue($options)); $this->setProxyViaReflection($proxy); $this->assertEquals($options, $this->element->getValueOptions()); $this->assertEquals($options, $this->element->getValueOptions()); }
public function testOptionsCanBeSetSingle() { $proxy = $this->getMock('DoctrineModule\\Form\\Element\\Proxy'); $proxy->expects($this->once())->method('setOptions')->with(array('is_method' => true)); $this->setProxyViaReflection($proxy); $this->element->setOption('is_method', true); }
public function __construct(ServiceLocatorInterface $serviceLocator, ObjectManager $objectManager) { parent::__construct('user-form'); $this->setAttribute('class', 'form-horizontal'); /** @var \Application\Filter\UserFilter $userFilter */ $userFilter = $serviceLocator->get("user-filter"); $this->setInputFilter($userFilter); $this->setObjectManager($objectManager); $translator = $serviceLocator->get('translator'); $id = new Hidden('id'); $this->add($id); $first_name = new Text('firstname'); $first_name->setLabel($translator->translate('First Name'))->setAttributes(['id' => 'user_first_name', 'class' => 'form-control input-circle']); $this->add($first_name); $last_name = new Text('lastname'); $last_name->setLabel($translator->translate('Last Name'))->setAttributes(['id' => 'user_last_name', 'class' => 'form-control input-circle']); $this->add($last_name); $username = new Text('username'); $username->setLabel($translator->translate('Username'))->setAttributes(['id' => 'user_username', 'class' => 'form-control input-circle']); $this->add($username); $email = new Email('email'); $email->setLabel($translator->translate('E-mail'))->setAttributes(['id' => 'user_email', 'class' => 'form-control input-circle']); $this->add($email); $password = new Password('password'); $password->setLabel($translator->translate('Password'))->setAttributes(['id' => 'user_password', 'class' => 'form-control input-circle', 'placeholder' => $translator->translate('Report to Update')]); $this->add($password); $level = new Select('level'); $level->setLabel($translator->translate('Level'))->setAttributes(['id' => 'user_level', 'class' => 'form-control select2me', 'options' => ['1' => $translator->translate('Super Admin'), '2' => $translator->translate('Admin'), '3' => $translator->translate('User')]]); $this->add($level); $ps = new Textarea('ps'); $ps->setLabel($translator->translate('PS'))->setAttributes(['id' => 'user_ps', 'class' => 'form-control input-circle', 'rows' => 5]); $this->add($ps); $language = new ObjectSelect('language'); $language->setLabel($translator->translate('Language'))->setAttributes(['id' => 'language', 'class' => 'form-control select2me'])->setOptions(['object_manager' => $this->getObjectManager(), 'target_class' => 'Application\\Entity\\WcLanguage', 'property' => 'name', 'empty_option' => $translator->translate('Select one Language'), 'is_method' => TRUE, 'find_method' => ['name' => 'findBy', 'params' => ['criteria' => [], 'orderBy' => ['name' => 'ASC']]]]); $this->add($language); $status = new Select('status'); $status->setLabel($translator->translate('Status'))->setAttributes(['id' => 'user_status', 'class' => 'form-control select2me', 'options' => ['1' => $translator->translate('Active'), '0' => $translator->translate('Desactive')]]); $this->add($status); $submit = new Button('submit'); $submit->setLabel($translator->translate('Save'))->setAttributes(['type' => 'submit', 'class' => 'btn-primary btn btn-circle pull-right ml-xs send']); $this->add($submit); }
/** * {@inheritDoc} */ public function setValue($value) { $multiple = $this->getAttribute('multiple'); if (true === $multiple || 'multiple' === $multiple) { if ($value instanceof Traversable) { $value = ArrayUtils::iteratorToArray($value); } elseif ($value == null) { return parent::setValue([]); } elseif (!is_array($value)) { $value = (array) $value; } return parent::setValue(array_map([$this, 'getValueOption'], $value)); } return parent::setValue($this->getValueOption($value)); }
public function __construct($name = null, $options = []) { $this->attributes['id'] = uniqid(); parent::__construct($name, $options); }