Comments (5)
Would you please provide $value
and corresponding model attribute values that are not correct?
from form.
Would you please provide
$value
and corresponding model attribute values that are not correct?
I think checkbox widget work fine - it generated input with current value of FormModel, like others inputs.
But I also think - need return boolean widget, that generated checkbox with static attribute value = 1 and optional hidden input with value 0
from form.
¿Podría proporcionar los valores de atributo del modelo correspondientes que no sean correctos?
$value
Creo que el widget de casilla de verificación funciona bien: generó entrada con el valor actual de FormModel, al igual que otras entradas.
Pero también creo que necesita un widget booleano de retorno, que generó una casilla de verificación con valor de atributo estático = 1 y entrada oculta opcional con valor 0
Line 229 in a00c7b7
Test Bool CheckBox:
form/tests/Widget/CheckboxTest.php
Line 82 in a00c7b7
As you can see there is a test suite for all possible values.
Could you show the code of your widget?
from form.
I think I understood your problem, checkbox always returns a value 0
or 1
, it does not return boolean
, if you want to save to your data, as a boolean value
you just have to cast (bool)
, checking the previous behavior of BooleanInput::class
the same
form/src/Widget/BooleanInput.php
Line 278 in 5c25f78
cast bool
, which you can do in the form, and thus maintain a uniform behavior.from form.
I think I understood your problem, checkbox always returns a value
0
or1
, it does not returnboolean
, if you want to save to your data, as aboolean value
you just have tocast (bool)
, checking the previous behavior ofBooleanInput::class
the sameform/src/Widget/BooleanInput.php
Line 278 in 5c25f78
with the difference that it converts the value
cast bool
, which you can do in the form, and thus maintain a uniform behavior.
No, problem is not in type cast. See - i write stand alone view file with simple model and form. Check Is active, send form and you will see result
test.zip
from form.
Related Issues (20)
- URL rule regex does not work in HTML field when IDN is enabled
- Use friendly exception for exception "Form model is not set."
- Implement template for each widget from factory. HOT 3
- Change FormModel::attributes as protected or add method like getAttributeNames HOT 6
- Use array_key_exists instead of isset on check value
- Adapt after removing result set in validator
- Rename FormErrors to FormErrorSet (and similar) - consistency, best practices HOT 1
- Nested::rule and nested forms validation fails
- Make use of PHP 8 attributes for labels, hints, etc.
- Nested rule - combine dot notation and nested structure
- Yiisoft\Form\Widget\Validator\FieldValidator::getValidatorAttributes() shouldn't apply required attribute for Required rule indiscriminately
- Remove filter of null values in methods for setting classes HOT 1
- Code style - chain calls HOT 15
- Add `$content` parameter to `Field::*Button()` methods
- Yiisoft\Validator\DataSet\AttributeDataSet not found
- Dependency update/adjust to yiisoft/html HOT 2
- Nested array form with translations HOT 3
- Checkbox don't accept label parameters HOT 1
- Input field name array HOT 1
- Add php attribute like #[SkipHydration] to skip private properties in collectAttributes() HOT 1
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.
from form.