-
-
Notifications
You must be signed in to change notification settings - Fork 75
Open
Description
Hi, I need some help, I can't get the select option to work.
I can only get "selects" to work with fastform
$opcoes = [
'4' => '4 Horas',
'24' => '1 Dia',
'48' => '2 Dias',
'72' => '3 Dias',
];
$data = [
'select' => [
'name' => 'duracao',
'label' => 'Duração: ',
'options' => $opcoes,
'selected' => '4'
]
];
$form->fastform($data);
Initially I had this:
$options = [
'4' => '4 Horas',
'24' => '1 Dia',
'48' => '2 Dias',
'72' => '3 Dias',
];
$form->select('duracao','Duração: ','','','','','4',$options);
I noticed in the method protected function _create_select($data) at the very end, this part doesn't work:
if (! empty($data['label'])) {
# output the element and label without a wrapper
$element .= $this->label($data).PHP_EOL;
$element .= $return.PHP_EOL;
return $element;
} else {
If I remove it and just run this it works:
$element .= $return.PHP_EOL;
return $this->_wrapper($element, $data);
Is this a bug or something I am missing? Do I have to set a wrapper? And why without a wrapper it doesn't work?
This is the section of code I'm talking about:
if (empty($data['fastform'])) {
if (! $this->wrapper) {
if ($this->comments) {
$element .= PHP_EOL.'<!-- '.$data['name'].' -->'.PHP_EOL;
}
if (! empty($data['label'])) {
# output the element and label without a wrapper
$element .= $this->label($data).PHP_EOL;
$element .= $return.PHP_EOL;
return $element;
} else {
# just return the element
$element .= $return.PHP_EOL;
return $this->_wrapper($element, $data);
}
} else {
# wrap the element
$element .= $return;
return $this->_wrapper($element, $data);
}
}
If I change it like this I get two labels:
if (empty($data['fastform'])) {
if (!$this->wrapper) {
if ($this->comments) {
$element .= PHP_EOL.'<!-- '.$data['name'].' -->'.PHP_EOL;
}
if (! empty($data['label'])) {
# output the element and label without a wrapper
$element .= $this->label($data).PHP_EOL;
}
# just return the element
$element .= $return.PHP_EOL;
return $this->_wrapper($element, $data);
} else {
# wrap the element
$element .= $return;
return $this->_wrapper($element, $data);
}
}
If I remove the label it seems to work but now I have two similar code parts but one has a PHP_EOL. Can you check what is happening here?
if (empty($data['fastform'])) {
if (!$this->wrapper) {
if ($this->comments) {
$element .= PHP_EOL.'<!-- '.$data['name'].' -->'.PHP_EOL;
}
# just return the element
$element .= $return.PHP_EOL;
return $this->_wrapper($element, $data);
} else {
# wrap the element
$element .= $return;
return $this->_wrapper($element, $data);
}
}
Metadata
Metadata
Assignees
Labels
No labels