本文整理汇总了PHP中Zend\Form\Element\Text::setValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Text::setValue方法的具体用法?PHP Text::setValue怎么用?PHP Text::setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\Element\Text
的用法示例。
在下文中一共展示了Text::setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __invoke
public function __invoke($name, $value, array $attributes = null)
{
$attributes = $this->setDefaultAttributes($attributes);
$element = new Text($name);
$element->setValue($value)->setAttributes($attributes);
return $this->render($element);
}
示例2: init
/** {@inheritdoc} */
public function init()
{
parent::init();
$inputFilter = new \Zend\InputFilter\InputFilter();
// Create list of values as array because nested iteration does not work with ResultSet objects.
$this->_definedValues = iterator_to_array($this->getOption('registryManager')->getValueDefinitions());
// Subform for enabling/disabling registry inspection, in addition to
// the same setting in preferences.
$fieldsetInspect = new \Zend\Form\Fieldset('inspect');
$inspect = new Element\Checkbox('inspect');
$inspect->setLabel('Inspect registry')->setChecked($this->getOption('config')->inspectRegistry);
$fieldsetInspect->add($inspect);
$this->add($fieldsetInspect);
// Subform for existing values
$fieldsetExisting = new \Zend\Form\Fieldset('existing');
$inputFilterExisting = new \Zend\InputFilter\InputFilter();
// Create text elements for existing values to rename them
foreach ($this->_definedValues as $value) {
$name = $value['Name'];
$elementName = "value_{$value['Id']}_name";
$element = new Element\Text($elementName);
$element->setValue($name)->setLabel($value['FullPath']);
$inputFilterExisting->add(array('name' => $elementName, 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('max' => 255)), $this->_createBlacklistValidator($name))));
$fieldsetExisting->add($element);
}
$this->add($fieldsetExisting);
$inputFilter->add($inputFilterExisting, 'existing');
// Subform for new value
$fieldsetNew = new \Zend\Form\Fieldset('new_value');
$newName = new Element\Text('name');
$newName->setLabel('Name');
$fieldsetNew->add($newName);
$newRootKey = new Element\Select('root_key');
$newRootKey->setLabel('Root key')->setAttribute('type', 'select_untranslated')->setValueOptions(\Model\Registry\Value::rootKeys())->setValue(\Model\Registry\Value::HKEY_LOCAL_MACHINE);
$fieldsetNew->add($newRootKey);
// Additional validation in isValid()
$newSubKeys = new Element\Text('subkeys');
$newSubKeys->setLabel('Subkeys');
$fieldsetNew->add($newSubKeys);
$newValue = new Element\Text('value');
$newValue->setLabel('Only this value (optional)');
$fieldsetNew->add($newValue);
$submit = new \Library\Form\Element\Submit('submit');
$submit->setLabel('Change');
$fieldsetNew->add($submit);
$this->add($fieldsetNew);
$inputFilterNew = new \Zend\InputFilter\InputFilter();
$inputFilterNew->add(array('name' => 'name', 'required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('max' => 255)), $this->_createBlacklistValidator())));
$inputFilterNew->add(array('name' => 'subkeys', 'continue_if_empty' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'Callback', 'options' => array('callback' => array($this, 'validateEmptySubkeys'), 'message' => "Value is required and can't be empty")), array('name' => 'StringLength', 'options' => array('max' => 255)))));
$inputFilterNew->add(array('name' => 'value', 'required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('max' => 255)))));
$inputFilter->add($inputFilterNew, 'new_value');
$this->setInputFilter($inputFilter);
}
示例3: load
/**
* Load textstring editor
*
* @return Element\Text
*/
public function load()
{
$parameters = $this->getConfig();
$property = $this->getProperty();
$textstring = new Element\Text($this->getName());
$textstring->setAttribute('class', 'form-control');
$textstring->setLabel($property->getName());
$textstring->setAttribute('id', $this->getName());
$textstring->setValue($this->getValue());
$textstring->setAttribute('required', $property->isRequired());
if (!empty($parameters['length'])) {
$textstring->setAttribute('maxlength', $parameters['length']);
}
return $textstring;
}
示例4: __construct
public function __construct(OrmCongregacao $orm = null)
{
parent::__construct("formProduto");
$txtId = new Element\Hidden("id");
$txtNome = new Element\Text("nome");
$txtNome->setAttributes(array('class' => 'form-control', 'placeholder' => 'Nome da Congregação', 'data-parsley-trigger' => 'change', 'pattern' => '^[aA-zZ]+((\\s[aA-zZ]+)+)?$', 'required' => 'true'));
$txtCep = new Element\Text("cep");
$txtCep->setAttributes(array('class' => 'form-control', 'placeholder' => 'XXXXXXXX', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]{2}[0-9]{3}[0-9]{3}$/', 'max-length' => '8', 'required' => 'true'));
$txtNumero = new Element\Text("numero");
$txtNumero->setAttributes(array('class' => 'form-control', 'placeholder' => 'Numero', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]+$/', 'max-length' => '6', 'required' => 'true'));
$txtLogradouro = new Element\Text("logradouro");
$txtLogradouro->setAttributes(array('class' => 'form-control', 'placeholder' => 'Ex: Rua, Avenida, Travessa...', 'required' => 'true'));
$txtBairro = new Element\Text("bairro");
$txtBairro->setAttributes(array('class' => 'form-control', 'required' => 'true'));
$txtCidade = new Element\Text("cidade");
$txtCidade->setAttributes(array('class' => 'form-control', 'required' => 'true'));
$txtUf = new Element\Text("uf");
$txtUf->setAttributes(array('class' => 'form-control', 'max-length' => '2', 'required' => 'true'));
$iToken = new Element\Csrf("iToken");
$btnSalvar = new Element\Button('salvar');
$btnSalvar->setAttributes(array('class' => 'btn btn-darkgray btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button'));
$btnVoltar = new Element\Button('voltar');
$btnVoltar->setAttributes(array('class' => 'btn btn-blue btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button'));
if ($orm != null) {
$txtId->setValue($orm->getId());
$txtNome->setValue($orm->getNome());
$txtCep->setValue($orm->getCep());
$txtNumero->setValue($orm->getNumero());
$txtLogradouro->setValue($orm->getLogradouro());
$txtBairro->setValue($orm->getBairro());
$txtCidade->setValue($orm->getCidade());
$txtUf->setValue($orm->getUf());
}
//
$this->add($txtId);
$this->add($txtNome);
$this->add($txtCep);
$this->add($txtNumero);
$this->add($txtLogradouro);
$this->add($txtBairro);
$this->add($txtCidade);
$this->add($txtUf);
$this->add($iToken);
$this->add($btnSalvar);
$this->add($btnVoltar);
$this->setAttributes(array('id' => 'form', 'data-parsley-validate' => NULL));
}
示例5:
function __construct($task_id, TaskService $taskService, DocumentService $documentService)
{
parent::__construct('console_queueitems');
$element_task_id = new Element\Hidden('task_id');
$this->add($element_task_id);
$element_task_id->setValue($task_id);
$element_task_title = new Element\Text('task_title');
$task = $taskService->getTask($task_id);
$element_task_title->setValue($task->title);
$this->add($element_task_title);
$element_document = new Element\Select('document');
$document_titles = $documentService->getDocumentTitles();
$element_document->setValueOptions($document_titles);
$this->add($element_document);
$element_address_type = new Element\Select('address_type');
$element_address_type->setValueOptions(array(self::ADDRESS_TYPE_ALL => '所有邮件地址', self::ADDRESS_TYPE_NEW => '新的邮件地址'));
$this->add($element_address_type);
$this->add(array('name' => 'submit', 'type' => 'Submit'));
}
示例6: __construct
/**
* Form initialization.
*
* @return void
*/
public function __construct()
{
parent::__construct();
// Job Name
$name = new Element\Text('name');
$name->setLabel('Job Name');
$name->setAttributes(array('autocomplete' => 'off', 'class' => 'form-control'));
$this->add($name);
// Expression
$expression = new Element\Text('expression');
$expression->setLabel('Time');
$expression->setValue('* * * * *');
$expression->setAttributes(array('autocomplete' => 'off', 'class' => 'form-control'));
$this->add($expression);
// Command
$command = new Element\Textarea('command');
$command->setLabel('Command');
$command->setAttributes(array('autocomplete' => 'off', 'class' => 'form-control command'));
$this->add($command);
}
示例7: load
/**
* Load Image cropper prevalue editor
*
* @return string
*/
public function load()
{
$config = $this->getConfig();
$resizeOption = new Element\Select('resize_option');
$resizeOption->setValue(empty($config['resize_option']) ? 'auto' : $config['resize_option'])->setAttribute('class', 'form-control')->setAttribute('id', 'resize-option')->setLabel('Resize option')->setLabelAttributes(array('class' => 'col-lg-2'))->setValueOptions(array('auto' => 'auto', 'crop' => 'crop'));
$backgroundOption = new Element\Text('background');
$backgroundOption->setValue(empty($config['background']) ? '' : $config['background'])->setAttribute('class', 'form-control')->setAttribute('id', 'background')->setLabel('Background color')->setLabelAttributes(array('class' => 'col-lg-2'));
$mimeList = new Element\MultiCheckbox('mime_list');
$mimeList->setAttribute('class', 'input-checkbox')->setLabel('Mime list')->setLabelAttributes(array('class' => 'col-lg-2'));
$array = array('image/gif', 'image/jpeg', 'image/png');
$options = array();
foreach ($array as $mime) {
$options[] = array('value' => $mime, 'label' => $mime, 'selected' => !in_array($mime, empty($config['mime_list']) ? array() : $config['mime_list']) ? false : true);
}
$mimeList->setValueOptions($options);
$sizeElements = array();
$idx = 0;
if (!empty($config['size'])) {
foreach ($config['size'] as $idx => $size) {
$elementSizeName = new Element\Text('size[' . $idx . '][name]');
$elementSizeName->setValue($size['name'])->setAttribute('class', 'form-control')->setAttribute('id', 'name' . $idx)->setLabel('Name');
$elementWidth = new Element\Text('size[' . $idx . '][width]');
$elementWidth->setValue($size['width'])->setAttribute('class', 'form-control')->setAttribute('id', 'width' . $idx)->setLabel('Width');
$elementHeight = new Element\Text('size[' . $idx . '][height]');
$elementHeight->setValue($size['height'])->setAttribute('class', 'form-control')->setAttribute('id', 'height' . $idx)->setLabel('Height');
$sizeElements[] = array($elementSizeName, $elementWidth, $elementHeight);
}
$idx++;
}
$elementSizeName = new Element\Text('size[#{idx}][name]');
$elementSizeName->setAttribute('id', 'name#{idx}')->setAttribute('class', 'form-control')->setLabel('Name');
$elementWidth = new Element\Text('size[#{idx}][width]');
$elementWidth->setLabel('Width')->setAttribute('class', 'form-control')->setAttribute('id', 'width#{idx}');
$elementHeight = new Element\Text('size[#{idx}][height]');
$elementHeight->setLabel('Height')->setAttribute('class', 'form-control')->setAttribute('id', 'height#{idx}');
$template = array($elementSizeName, $elementWidth, $elementHeight);
return $this->addPath(__DIR__)->render('upload-prevalue.phtml', array('elements' => array('resize-option' => $resizeOption, 'background' => $backgroundOption, 'mime' => $mimeList, 'size' => $sizeElements, 'size-template' => $template)));
}
示例8: setValue
/**
*
* @param mixed $value
* @return void
* @throws \RuntimeException
*/
public function setValue($value)
{
if (!is_object($value)) {
if (is_array($value) && array_key_exists('id', $value)) {
$this->setAttribute('data-zf2doctrineacid', $value['id']);
return parent::setValue($value[$this->getProxy()->getProperty()]);
} else {
$this->setAttribute('data-zf2doctrineacid', $value);
return parent::setValue($value);
}
}
$id = $this->getProxy()->getValue($value);
$this->setAttribute('data-zf2doctrineacid', $id);
$metadata = $this->getProxy()->getObjectManager()->getClassMetadata($this->getProxy()->getTargetClass());
$identifier = $metadata->getIdentifierFieldNames();
$object = $this->getProxy()->getObjectManager()->getRepository($this->getProxy()->getTargetClass())->find($id);
if (is_callable($this->getOption('label_generator')) && null !== ($generatedLabel = call_user_func($this->getOption('label_generator'), $object))) {
$label = $generatedLabel;
} elseif ($property = $this->getProxy()->getProperty()) {
if ($this->getProxy()->getIsMethod() == false && !$metadata->hasField($property)) {
throw new RuntimeException(sprintf('Property "%s" could not be found in object "%s"', $property, $targetClass));
}
$getter = 'get' . ucfirst($property);
//var_dump(get_class($object));
//var_dump(get_class_methods($object));
if (!is_callable(array($object, $getter))) {
throw new RuntimeException(sprintf('Method "%s::%s" is not callable', $this->getProxy()->getTargetClass(), $getter));
}
$label = $object->{$getter}();
} else {
if (!is_callable(array($object, '__toString'))) {
throw new RuntimeException(sprintf('%s must have a "__toString()" method defined if you have not set a property' . ' or method to use.', $this->getProxy()->getTargetClass()));
}
$label = (string) $object;
}
return parent::setValue($label);
}
示例9: __construct
public function __construct()
{
parent::__construct();
$this->setAttribute('method', 'post');
$this->setAttribute('class', 'panel-body');
$name = new Text('name');
$name->setLabel('name');
$name->setAttribute('class', 'form-control');
$this->add($name);
$type = new Select('inputType');
$type->setAttribute('class', 'form-control');
$type->setLabel('input.type');
$type->setValueOptions([self::INPUT_TYPE_TEXT, self::INPUT_TYPE_TEXTAREA, self::INPUT_TYPE_DATE, self::INPUT_TYPE_TIME, self::INPUT_TYPE_DATETIME, self::INPUT_TYPE_PICTURE_UPLOAD]);
$this->add($type);
$orderPriority = new Text('orderPriority');
$orderPriority->setLabel('order.priority');
$orderPriority->setAttribute('class', 'form-control');
$orderPriority->setValue(0);
$this->add($orderPriority);
$submit = new Submit('save');
$submit->setValue('save');
$submit->setAttribute('class', 'btn btn-primary');
$this->add($submit);
}
示例10: __construct
public function __construct(OrmNivel $orm = null)
{
parent::__construct("formNivel");
/*
* txtId
*/
$txtId = new Element\Hidden("id");
$txtNome = new Element\Text("nome");
$txtNome->setAttributes(array('class' => 'form-control', 'placeholder' => 'Nome da Categoria', 'data-parsley-trigger' => 'change', 'pattern' => '^[aA-zZ]+((\\s[aA-zZ]+)+)?$', 'required' => 'true'));
/*
* chkDashbord
*/
$chkDashbord = new Element\Checkbox('dashboard');
$chkDashbord->setAttributes(array('id' => "switch01", 'class' => 'onoffswitch-checkbox'));
$chkPublicador = new Element\Checkbox('publicador');
$chkPublicador->setAttributes(array('id' => "switch02", 'class' => 'onoffswitch-checkbox'));
/*
* chkCongregacao
*/
$chkCongregacao = new Element\Checkbox('congregacao');
$chkCongregacao->setAttributes(array('id' => "switch07", 'class' => 'onoffswitch-checkbox'));
/*
* chkRelatorio
*/
$chkRelatorio = new Element\Checkbox('relatorio');
$chkRelatorio->setAttributes(array('id' => "switch03", 'class' => 'onoffswitch-checkbox'));
/*
* chkGrupo
*/
$chkGrupo = new Element\Checkbox('grupo');
$chkGrupo->setAttributes(array('id' => "switch04", 'class' => 'onoffswitch-checkbox'));
/*
* chkUsuario
*/
$chkUsuario = new Element\Checkbox('usuario');
$chkUsuario->setAttributes(array('id' => "switch05", 'class' => 'onoffswitch-checkbox'));
/*
* chkNivel
*/
$chkNivel = new Element\Checkbox('nivel');
$chkNivel->setAttributes(array('id' => "switch06", 'class' => 'onoffswitch-checkbox'));
/*
* chkPrivilegios
*/
$chkPrivilegios = new Element\Checkbox('privilegios');
$chkPrivilegios->setAttributes(array('id' => "switch07", 'class' => 'onoffswitch-checkbox'));
/*
* chkEscolaMinisterio
*/
$chkEscolaMinisterio = new Element\Checkbox('escola');
$chkEscolaMinisterio->setAttributes(array('id' => "switch08", 'class' => 'onoffswitch-checkbox'));
/*
* iToken
*/
$iToken = new Element\Csrf("iToken");
/*
* btnSalvar
*/
$btnSalvar = new Element\Button('salvar');
$btnSalvar->setAttributes(array('class' => 'btn btn-darkgray btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button'));
/*
* btnVoltar
*/
$btnVoltar = new Element\Button('voltar');
$btnVoltar->setAttributes(array('class' => 'btn btn-blue btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button'));
/*
* Preencher Objetos
*/
if ($orm != null) {
$txtId->setValue($orm->getId());
$txtNome->setValue($orm->getNome());
$chkDashbord->setValue($orm->getDashboard());
$chkPublicador->setValue($orm->getPublicador());
$chkGrupo->setValue($orm->getGrupo());
$chkCongregacao->setValue($orm->getCongregacao());
$chkRelatorio->setValue($orm->getRelatorio());
$chkUsuario->setValue($orm->getUsuario());
$chkPrivilegios->setValue($orm->getPrivilegios());
$chkEscolaMinisterio->setValue($orm->getEscolaMinisterio());
$chkNivel->setValue($orm->getNivel());
}
/*
* Adiciona Objetos ao form
*/
$this->add($txtId);
$this->add($txtNome);
$this->add($chkDashbord);
$this->add($chkPublicador);
$this->add($chkGrupo);
$this->add($chkRelatorio);
$this->add($chkCongregacao);
$this->add($chkUsuario);
$this->add($chkNivel);
$this->add($chkPrivilegios);
$this->add($chkEscolaMinisterio);
$this->add($iToken);
$this->add($btnSalvar);
$this->add($btnVoltar);
/*
* Form
//.........这里部分代码省略.........
示例11: __construct
public function __construct(EntityManager $em, OrmPublicador $tipoPrivilegio = null, OrmPrivilegios $orm = null)
{
parent::__construct("formPrivilegios");
// var_dump($option);
// exit();
/*
* txtID
*/
$txtId = new Element\Hidden("id");
/*
* txtNome
*/
$txtDataInicio = new Element\Text("dataInicio");
$txtDataInicio->setAttributes(array('class' => 'form-control', 'placeholder' => 'XX/XX/XXXX', 'max-length' => '10', 'required' => 'true'));
$txtDataTermino = new Element\Text("dataTermino");
$txtDataTermino->setAttributes(array('class' => 'form-control', 'placeholder' => 'XX/XX/XXXX', 'max-length' => '10'));
/*
* cmbPublicador
*/
$dao = $em->getRepository('Stj\\Entity\\OrmPublicador');
if (empty($tipoPrivilegio)) {
$lista = $dao->findAll();
} else {
$lista = $dao->ListALLWhere($tipoPrivilegio->getId());
}
$option = array();
foreach ($lista as $key => $value) {
$tipoPrivilegio = new OrmPublicador();
$tipoPrivilegio = $value;
$option[$tipoPrivilegio->getId()] = $tipoPrivilegio->getNome();
}
$cmbPublicador = new Element\Select('publicador');
$cmbPublicador->setValueOptions($option);
$cmbPublicador->setEmptyOption("Selecionar");
$cmbPublicador->setAttributes(array('class' => 'chosen-select', 'style' => 'width:175px;', 'required' => 'true'));
/*
* cmbPrivilegio
*/
$dao = $em->getRepository('Stj\\Entity\\OrmTipoPrivilegios');
$lista = $dao->findAll();
$option = array();
foreach ($lista as $key => $value) {
$tipoPrivilegio = new OrmTipoPrivilegios();
$tipoPrivilegio = $value;
$option[$tipoPrivilegio->getId()] = $tipoPrivilegio->getNome();
}
$cmbPrivilegio = new Element\Select('privilegio');
$cmbPrivilegio->setValueOptions($option);
$cmbPrivilegio->setEmptyOption("Selecionar");
$cmbPrivilegio->setAttributes(array('class' => 'chosen-select', 'style' => 'width:175px;', 'required' => 'true'));
/*
* Itoken
*/
$iToken = new Element\Csrf("iToken");
/*
* btnSalvar
*/
$btnSalvar = new Element\Button('salvar');
$btnSalvar->setAttributes(array('class' => 'btn btn-darkgray btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button'));
/*
* btnVoltar
*/
$btnVoltar = new Element\Button('voltar');
$btnVoltar->setAttributes(array('class' => 'btn btn-blue btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button'));
/*
* Preencher Componentes
*/
if ($orm != null) {
$txtId->setValue($orm->getId());
$txtDataInicio->setValue($orm->getDataInicio() != "" ? $orm->getDataInicio()->format('d/m/Y') : "");
$txtDataTermino->setValue($orm->getDataTermino() != "" ? $orm->getDataTermino()->format('d/m/Y') : "");
$cmbPrivilegio->setValue($orm->getTipoPrivilegio()->getId());
$cmbPublicador->setValue($orm->getPublicador()->getId());
}
// Adiciona componetes no form
$this->add($txtId);
$this->add($txtDataInicio);
$this->add($txtDataTermino);
$this->add($cmbPublicador);
$this->add($cmbPrivilegio);
$this->add($iToken);
$this->add($btnSalvar);
$this->add($btnVoltar);
$this->setAttributes(array('id' => 'form', 'data-parsley-validate' => NULL));
}
示例12: addTab
/**
* Add tab sub form
*
* @param mixed $tab \Gc\Tab\Model|array
*
* @return DocumentType
*/
public function addTab($tab)
{
if (!is_array($tab) and !$tab instanceof Tab\Model) {
return $this;
}
$fieldsets = $this->getTabs();
$name = new Element\Text('name');
$description = new Element\Text('description');
$tabId = new Element\Hidden('tab_id');
if ($tab instanceof Tab\Model) {
$name->setValue($tab->getName());
$description->setValue($tab->getDescription());
$tabId->setValue($tab->getId());
$tabFieldsetName = $tab->getId();
} else {
$name->setValue($tab['name']);
$description->setValue($tab['description']);
$tabId->setValue(str_replace('tab', '', $tab['id']));
$tabFieldsetName = $tab['id'];
}
$tabForm = new FieldSet($tabFieldsetName);
$fieldsets->add($tabForm);
$tabForm->add($name);
$tabForm->add($description);
$tabForm->add($tabId);
//Input filter
$this->getInputFilter()->get('tabs')->add(array('type' => 'Zend\\InputFilter\\InputFilter', 'name' => array('name' => 'name', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'description' => array('name' => 'description', 'required' => true, 'validators' => array(array('name' => 'not_empty')))), $tabFieldsetName);
return $this;
}
示例13: testGetValue
/**
* Test
*
* @return void
*/
public function testGetValue()
{
$this->assertNull($this->object->getValue('undefined'));
$element = new Element\Text('text');
$element->setValue('string');
$this->object->add($element);
$this->assertEquals('string', $this->object->getValue('text'));
}
示例14: __construct
public function __construct(EntityManager $em, OrmPublicador $orm = null, $publicador = null)
{
parent::__construct("formPublicador");
$dao = $em->getRepository('Stj\\Entity\\OrmGrupo');
if ($publicador == null) {
$lista = $dao->findAll();
} else {
$lista = $dao->ListALL(FALSE, $publicador->getGrupo()->getCongregacao());
}
$option = array();
$grupoarray = array();
$i = 0;
$nomeCongregacao = "";
foreach ($lista as $key => $value) {
$grupo = new OrmGrupo();
$grupo = $value;
if ($nomeCongregacao != "") {
if ($grupo->getCongregacao()->getNome() == $nomeCongregacao) {
$option[$grupo->getCongregacao()->getNome()]['options'][$grupo->getId()] = $grupo->getNome();
} else {
$option[$grupo->getCongregacao()->getNome()] = array('label' => $grupo->getCongregacao()->getNome());
$option[$grupo->getCongregacao()->getNome()]['options'][$grupo->getId()] = $grupo->getNome();
}
} else {
$option[$grupo->getCongregacao()->getNome()] = array('label' => $grupo->getCongregacao()->getNome());
$option[$grupo->getCongregacao()->getNome()]['options'][$grupo->getId()] = $grupo->getNome();
}
$nomeCongregacao = $grupo->getCongregacao()->getNome();
}
/*
* txtID
*/
$txtId = new Element\Hidden("id");
/*
* txtNome
*/
$txtNome = new Element\Text("nome");
$txtNome->setAttributes(array('class' => 'form-control', 'placeholder' => 'Nome do Publicador', 'data-parsley-trigger' => 'change', 'pattern' => '^[aA-zZ]+((\\s[aA-zZ]+)+)?$', 'required' => 'true'));
/*
* cmbGrupo
*/
$cmbGrupo = new Element\Select('grupo');
$cmbGrupo->setValueOptions($option);
$cmbGrupo->setEmptyOption("Escolha o grupo");
$cmbGrupo->setAttributes(array('class' => 'chosen-select', 'style' => 'width:140px;', 'required' => 'true'));
/*
* cmbClasse
*/
$cmbClasse = new Element\Select('classe');
$cmbClasse->setValueOptions(array('OO' => 'Outra Ovelha', 'U' => 'Ungido'));
$cmbClasse->setEmptyOption("Escolha a classe");
$cmbClasse->setAttributes(array('class' => 'chosen-select', 'style' => 'width:140px;', 'required' => 'true'));
/*
* cmbSexo
*/
$cmbSexo = new Element\Select('sexo');
$cmbSexo->setValueOptions(array('M' => 'Masculino', 'F' => 'Feminino'));
$cmbSexo->setEmptyOption("Escolha o sexo");
$cmbSexo->setAttributes(array('class' => 'chosen-select', 'style' => 'width:140px;', 'required' => 'true'));
/*
* txtdataNascimento
*/
$txtNascimento = new Element\Text("nascimento");
$txtNascimento->setAttributes(array('class' => 'form-control', 'placeholder' => 'XX/XX/XXXX', 'max-length' => '10'));
/*
* txtdataEmissao
*/
$txtEmissao = new Element\Text("emissao");
$txtEmissao->setAttributes(array('class' => 'form-control', 'placeholder' => 'XX/XX/XXXX', 'max-length' => '10'));
/*
* txtTelefone
*/
$txtTelefone = new Element\Text("telefone");
$txtTelefone->setAttributes(array('class' => 'form-control', 'placeholder' => '(11)1234-1234', 'max-length' => '13', 'data-parsley-trigger' => "change", 'pattern' => "^\\([0-9]{2}\\)[0-9]{4}-[0-9]{4}"));
/*
* txtCelular
*/
$txtCelular = new Element\Text("celular");
$txtCelular->setAttributes(array('class' => 'form-control', 'placeholder' => '(11)12345-1234', 'max-length' => '14', 'data-parsley-trigger' => "change", 'pattern' => "^\\([0-9]{2}\\)[0-9]{5}-[0-9]{4}"));
/*
* txtCep
*/
$txtCep = new Element\Text("cep");
$txtCep->setAttributes(array('class' => 'form-control', 'placeholder' => 'XXXXXXXX', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]{2}[0-9]{3}[0-9]{3}$/', 'max-length' => '8'));
/*
* txtNumero
*/
$txtNumero = new Element\Text("numero");
$txtNumero->setAttributes(array('class' => 'form-control', 'placeholder' => 'Numero', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]+$/', 'max-length' => '6'));
/*
* txtLogradouro
*/
$txtLogradouro = new Element\Text("logradouro");
$txtLogradouro->setAttributes(array('class' => 'form-control', 'placeholder' => 'Ex: Rua, Avenida, Travessa...'));
/*
* txtComplemento
*/
$txtComplemento = new Element\Text("complemento");
$txtComplemento->setAttributes(array('class' => 'form-control', 'placeholder' => 'Ex: Rua, Avenida, Travessa...'));
/*
//.........这里部分代码省略.........
示例15: __construct
public function __construct(EntityManager $em, OrmRelatorio $orm = null)
{
parent::__construct("formRelatorio");
/*
* txtID
*/
$txtId = new Element\Hidden("id");
/*
* txtAno
*/
$option = array();
$ano = 0;
if (date("m") >= 9) {
$ano = 1;
}
$ano = $ano + date("Y");
$option[$ano] = $ano;
$option[$ano - 1] = $ano - 1;
$cmbAno = new Element\Select('ano');
$cmbAno->setValueOptions($option);
$cmbAno->setEmptyOption("Escolha o ano");
$cmbAno->setAttributes(array('class' => 'chosen-select', 'style' => 'width:140px;', 'required' => 'true'));
/*
* txtMes
*/
setlocale(LC_ALL, 'pt_BR', 'pt_BR.utf-8', 'pt_BR.utf-8', 'portuguese');
date_default_timezone_set('America/Sao_Paulo');
$option = array();
for ($index = 1; $index < 13; $index++) {
$option[$index] = strftime("%B", strtotime(date("Y") . "/" . $index . "/01"));
}
$cmbMes = new Element\Select('mes');
$cmbMes->setValueOptions($option);
$cmbMes->setEmptyOption("Escolha o ano");
$cmbMes->setAttributes(array('class' => 'chosen-select', 'style' => 'width:140px;', 'required' => 'true'));
/*
* cmbPublicador
*/
$dao = $em->getRepository('Stj\\Entity\\OrmPublicador');
$lista = $dao->findAll();
$option = array();
foreach ($lista as $key => $value) {
$congregacao = new OrmCongregacao();
$congregacao = $value;
$option[$congregacao->getId()] = $congregacao->getNome();
}
$cmbPublicador = new Element\Select('publicador');
$cmbPublicador->setValueOptions($option);
$cmbPublicador->setEmptyOption("Escolha o publicador");
$cmbPublicador->setAttributes(array('class' => 'chosen-select', 'style' => 'width:140px;', 'required' => 'true'));
/*
* txtLivros
*/
$txtPublicacoes = new Element\Number("publicacoes");
$txtPublicacoes->setAttributes(array('class' => 'form-control', 'placeholder' => 'Quantidade', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]+$/', 'data-parsley-maxlength' => "3", 'required' => 'true'));
/*
* $txtVideos
*/
$txtVideos = new Element\Number("videos");
$txtVideos->setAttributes(array('class' => 'form-control', 'placeholder' => 'Quantidade', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]+$/', 'data-parsley-maxlength' => "3", 'required' => 'true'));
/*
* $txtPublicacoes
*/
$txtHoras = new Element\Text("horas");
$txtHoras->setAttributes(array('class' => 'form-control', 'placeholder' => 'HH:MM', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]+\\:[0-9]{2}$/', 'data-parsley-maxlength' => "6", 'required' => 'true'));
/*
* txtRevisitas
*/
$txtRevisitas = new Element\Number("revisitas");
$txtRevisitas->setAttributes(array('class' => 'form-control', 'placeholder' => 'Quantidade', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]+$/', 'data-parsley-maxlength' => "2", 'required' => 'true'));
/*
* txtEstudos
*/
$txtEstudos = new Element\Number("estudos");
$txtEstudos->setAttributes(array('class' => 'form-control', 'placeholder' => 'Quantidade', 'data-parsley-trigger' => 'change', 'pattern' => '/^[0-9]+$/', 'data-parsley-maxlength' => "2", 'required' => 'true'));
/*
* txtObs
*/
$txtObs = new Element\Textarea("obs");
$txtObs->setAttributes(array('class' => 'form-control', 'placeholder' => 'Digites suas observações aqui'));
/*
* Itoken
*/
$iToken = new Element\Csrf("iToken");
/*
* btnSalvar
*/
$btnSalvar = new Element\Button('salvar');
$btnSalvar->setAttributes(array('class' => 'btn btn-darkgray btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button'));
/*
* btnVoltar
*/
$btnVoltar = new Element\Button('voltar');
$btnVoltar->setAttributes(array('class' => 'btn btn-blue btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button'));
/*
* Preencher Componentes
*/
if ($orm != null) {
$txtId->setValue($orm->getId());
$cmbAno->setValue($orm->getAno());
//.........这里部分代码省略.........