Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG]: Phalcon\Html\Helper\Input\Select not working correctly #16625

Open
FaimMedia opened this issue Jul 13, 2024 · 1 comment
Open

[BUG]: Phalcon\Html\Helper\Input\Select not working correctly #16625

FaimMedia opened this issue Jul 13, 2024 · 1 comment
Assignees
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: medium Medium

Comments

@FaimMedia
Copy link

FaimMedia commented Jul 13, 2024

Describe the bug
Following this example: https://docs.phalcon.io/5.7/volt/#tag-helpers
It shows you should place inputSelect in a loop chained to an add function to add options. Not surprisingly, this just spits out x number of select fields, with only one option (see screenshots). So obviously the documentation is wrong here, but reviewing the source, I cannot find a method for adding a list of options directly? (Phalcon 3.4 had a using option: https://docs.phalcon.io/3.4/volt/#using-tag-helpers).
How to do this in Phalcon 5.7?

To Reproduce
Steps to reproduce the behavior:

$this->view->typeOptions = [
    4 => 'Type 4',
    8 => 'Type 8',
];
<div class="row row-label">
    <label>Type:</label>

    {% for id, name in typeOptions %}
        {{ inputSelect('type').addPlaceholder('Select type').add(name, id) }}
    {% endfor %}
</div>

Expected behavior
One select field with provided multiple options.

// paste code

Screenshots
If applicable, add screenshots to help explain your problem.

Scherm­afbeelding 2024-07-13 om 15 03 19 Scherm­afbeelding 2024-07-13 om 15 03 09

Details

  • Phalcon version: 5.7
  • PHP Version: PHP 8.3
  • Operating System: Alpine Linux
  • Installation type: Source
  • Server: Nginx
@FaimMedia FaimMedia added bug A bug report status: unverified Unverified labels Jul 13, 2024
@niden
Copy link
Member

niden commented Jul 13, 2024

I might have to rewrite this component. There are a couple of features that are a bit difficult to use to get the result you need.

This code should do what you need to do:

$this->view->typeOptions = [
    4 => 'Type 4',
    8 => 'Type 8',
];
<div class="row row-label">
    <label>Type:</label>
    {% assign select = inputSelect('    ', PHP_EOL, ['name' : 'type', 'placeHolder' : 'Select type']) %}

    {% for id, name in typeOptions %}
        {{ select.add(name, id) }}
    {% endfor %}
    {{ select }}
</div>

I am thinking, in alignment with what you mention, to have more methods for this. For instance we can have a method setAttributes to change whatever we like before the element is rendered and also have something like setOptions that will accept the array (the same thing as using)

I will work on this most likely this weekend.

@niden niden self-assigned this Jul 13, 2024
@niden niden added status: medium Medium 5.0 The issues we want to solve in the 5.0 release and removed status: unverified Unverified labels Jul 13, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: medium Medium
Projects
Status: Active Sprint
Development

No branches or pull requests

2 participants