-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SelectOption: Add method getLabel()
and change method setLabel()
#70
SelectOption: Add method getLabel()
and change method setLabel()
#70
Conversation
Please rebase here, there's a new test covering this change. |
72434e5
to
7fd8404
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this PR, i.e. why do you have to change the label after construction? Also, there's setContent()
and getContent()
which could just be used on the element.
e60b273
to
b444565
Compare
I noticed that label can be null in the constructor. It makes no sense to have an option without label. Maybe this should be fixed in a separate PR. |
So you have updated the description. I suppose now it's just a matter of |
We'll talk about that later. option can be used in several places and here and there it applies to have no value. For a select option, of course, this makes no sense. However, value could be empty, which then defaults to the content. I will create an issue for all this later. First, I want to understand what you want to do with the label. |
I have a use case for |
@sukhwinder33445 This can be closed, right? |
Talked with @nilmerg about this. I'll review the PR and we add it (maybe 😆). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to the requested changes, setLabel()
must NOT be removed, see here for a usage example.
I would like to see the following tests:
testRendering
testRenderingAfterSetLabel
testGetLabel
testGetLabelAfterSetLabel
4982037
to
f2ec9ec
Compare
f2ec9ec
to
440d09c
Compare
ff6551f
to
31f40ed
Compare
As we're changing this so fundamentally, may I ask what the purpose of a |
Not having a label is questionable though. |
31f40ed
to
9985e4b
Compare
9985e4b
to
6583208
Compare
321bbf9
to
0860464
Compare
0860464
to
560868a
Compare
Easily get the label of the select element's value
SelectOption now has its own test class
dd6fb7d
to
3815410
Compare
…70) * SelectOption: Add method `getLabel()` and phpdoc Easily get the label of the select element's value * Introduce class `SelectOptionTest` * SelectElementTest: Remove method `testLabelCanBeChanged()` SelectOption now has its own test class
…70) * SelectOption: Add method `getLabel()` and phpdoc Easily get the label of the select element's value * Introduce class `SelectOptionTest` * SelectElementTest: Remove method `testLabelCanBeChanged()` SelectOption now has its own test class
This PR allows to easily get the label of the selected option.
getContect()
returns an array ofValidHtml[]
and makes it harder to get the label as string.Usage:
$form->getElement('user')->getOption($form->getValue('user'))->getLabel()