Comments (2)
class
is an attribute, not an option:
$valueOptions = [];
foreach (countries() as $country) {
$valueOptions[] = [
'name' => $country['name'],
'attributes' => [
'class' => 'fi fi-' . strtolower($country['iso_3166_1_alpha2']),
],
'value' => $country['iso_3166_1_alpha2'],
'label' => $country['name'] . ' (+' . $country['calling_code'] . ')',
];
}
usort($valueOptions, static fn($a, $b) => $a['name'] <=> $b['name']);
$element = new Select(self::COUNTRY_CALLING_CODE);
$element->setLabel('Country calling code');
$element->setValueOptions($valueOptions);
There is a test asserting class attribute is utilized, so marking this as not a bug:
from laminas-form.
This can also be found in the documentation:
Attributes on the options are supported by providing the options as a specification array instead of key-value pairs:
https://docs.laminas.dev/laminas-form/v3/element/select/#basic-usage
from laminas-form.
Related Issues (20)
- Fix 3.1.1 also for 2.17.0 HOT 26
- CSRF element overwrites name option with element name HOT 3
- Removal of `container-interop/container-interop`
- After update from 2.17 to 3.1.1: Nested fieldset results in TypeError: template is undefined HOT 3
- Problems in tests with collections and setValidationGroup() HOT 3
- FormAttributeBuilder exception break on php 7.4 HOT 9
- Github pages isn't working( HOT 7
- Dependency Dashboard
- Add onfocusout on $validGlobalAttributes HOT 1
- ComposedObject annotation doesn't work with Required(false)
- Can't require latest package version when using PHP 8.0 running composer HOT 4
- Ability to wrap element for complex form rendering HOT 4
- Bug of day 31 (Element\Month) HOT 4
- keys(option-values) generation in get(Hours|Minutes|Seconds|...)Options HOT 3
- DateTime related elements should accept DateTimeInterface values HOT 1
- Date pattern parsing fails with "exotic" locales HOT 6
- Date/Time selects helpers __invoke args may have no effect
- IntlDateFormatter::SHORT is not handled correctly by date-time select helper HOT 1
- [RFC] Improve type inference for `getData()` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.