I am seeing this in Edge and IE.
I have a checkbox which is being initialized using initialValues to true.
On first visit its is displayed correctly as checked with a value of true, however after refreshing the page via the browser, the checkbox is not checked but still has a value of true. As i can continue to refresh the page the checkbox continues to switch in this way checked then unchecked on next refresh. redux form 7.2.3 react 15.6.2.
Thanks
The value of a checkbox is what will be associated with its name if it is checked. Checking a checkbox should not change the value, it should change the checked property.
This is not specific to redux-form, it is just how form elements are intended to work. It looks like redux-form wants to use value instead, and it doesn't work right.
In any case, I think you want to specifically handle the checked property with something like checked={value}.
Roy's answer is correct. Adding some redux-form context, passing checked to a Field component will override the normal behaviour. The normal behaviour is to compare if the value stored in redux-form's state is the same as the value prop specified on Field if so the checked prop is true.
So for example if the store state is values: { test: true } and your Field has value={true} then the end result is the checked prop is true.
The F5 refreshing toggle most likely suggests that your values initialization is changing on each refresh. It's hard to help you beyond a general statement like this without clear reproduction steps.
Related
I am currently using antd-form-builder to build multiple JSON forms for different components and I have an issue with antd trying to use a checkbox to disable another input.. basically I have a function that returns the form meta fields and then in the onChange for the checkbox I am trying to set another field to become disabled
what I have managed to find so far is for the form ref there is a setFields function and I can use this to change the value of another field or the errors on that field through the onChange of the checkbox, however, I cannot change the disabled state of another field.
turns out, this cant be done .. and state variables should be used as mentioned in the issue here
I have a gist demonstrating my problem here:
https://gist.run/?id=e2ccd5925e383f2fc36ad277c31bcf23
The checkbox version works fine, if you remove a check, it updates the model right, but if you change the selected radio button, it will keep the true value on the radio that got it's selection removed. If I remove the model.bind="true" value, it will write "on" instead of true. I do want true/false, and not on/off.
I want the object to get it's property updated to be a true or false depending on if it's chosen or not, dynamically. In my scenario I don't know how many radio buttons or checkboxes will need to be selected. I only know that in the cases of it not being a collection, I only want one, and in the case that it is a collection, I want an unknown number selected.
Like the other answer mentions - <input type="checkbox"> behavior is different from <input type="radio">.
I have forked your gist and made the following changes to make your scenario with the radio button work in aurelia:
1) Added a function to the first object in your params collection called selectedChanged(it doesn't have to be there, could be on the viewmodel class instead, perhaps a better place for it). It is responsible for handling selection change in the radio button group, specifically it will iterate over a collection of options (second parameter), and set selected property to true on the option who's id matches the first parameter of the function, and to false on all other options.
2) There is an event on the input called change, I delegate it to a function called selectedChanged mentioned above, passing the option.id value and options as parameters.
https://gist.run/?id=5f38414fde799dfc145fc1291d9f2fd3&sha=f12283b08bfb45e77b8280d46a3709b6ccb82768
I think what you want to achieve (turning individual value on/off) is not achievable with radio, as the way it works (select a single value out of a set) is different with check-box (turning individual value on/off) (MDN reference). So If you truly want to have radio like appearance, with check-box behavior, consider employing some CSS and extra DOM elements to make it look like so, and behave like so.
I am using $dirty to check the changes in a form ,but if i type something in the input box and remove it, the $dirty is still true.Is there any solution or it will work like this.
That is by design. Any form becomes $dirty whenever the user interacts with it, and you cannot undo the interaction event. Though you can restore defaults, that is clearly not the same.
Consider using $watch to check whether new value is different from the default one, and $setPristine() to clear user input.
$dirty means The field has been modified one more time. for compare your model by your previous model you can use $watch in controller.
if your field is empty you have a solution must set required attribute and in your input tag and use below code set ng-validate of your form to novalidate and then use below code for compare:
formName.inputName.$dirty && formName.inputName.$error.required
$Dirty refers to the form field is modified and you want to check using $pristine
I am using AutoIt to automate a Windows application for testing. I would like to be able to set the state of a three state checkbox that is by default indeterminate.
I have tried using ControlCommand(.., .., .., "Uncheck", ..) to set the "unchecked" state but it remains at indeterminate.
When I use "Check" in ControlCommand it moves the CheckBox from Indeterminate to False because that is the order of clicks:
Indeterminate
Unchecked
Checked
Is there a way to set the state programatically using AutoIt, without assuming the default state and counting the number of clicks myself?
A Checkbox is in fact a special version of a button. Don't ask why, it's MS and they thought that was a good idea.
You can do exactly what you want using the _GUICtrlButton_SetCheck function, there is an example in the helpfile here:
_GUICtrlButton_SetCheck($idChk, $BST_INDETERMINATE)
Is there any way to know the current value of a checkbox in wicket before any action takes place?
wantOnSelectionChangedNotifications() is not useful for me, I want to know the value of the checkbox before clicking on it.
Thanks
first of all in the server you cannot know the state of the input with out a form.
use AjaxFormComponentUpdatingBehavior or AjaxFormSubmitBehavior to attach the event to the checkbox and submit their form. with this aproach you going to submit all components inside the form, if you just want the value of the check you could use a nested form(wicket include support for it)