Closed haruyama closed 9 years ago
I think again that errors.NewElementNotFound() is useful. I add definedFileds to Form.
We should look into setting non-existent form elements via the Input()
method without removing the field checks. I want to be able to catch unintentionally setting a non-existent form fields. For instance when accidentally setting the name
argument to "usernam" instead of "username", which could cause difficult to find bugs.
I assumed I would eventually add a Checkbox()
method. That might be a better spot for manipulating checkboxes.
Now my code checks field-existance in Input(), using Form.definedFields.
I also want to add "Checkbox(values []string, field string) error".
I've been procrastinating on adding full support for checkboxes because they can be a little tricky at times. Just keep in mind that browsers don't submit unchecked checkboxes, and they need to be filtered out in Form.send()
.
I don't know your "full support for checkboxes"....
I just added Form.InputSlice() and Form.Checkbox() which set multi-values to field. If you want to all-unchecked checkbox field, you set zero-length slice( []string{} ) as values. Or we will add Form.Delete(name string).
Note: My code does not validate checkbox values.
I'll take a look at this patch shortly. I just go back from vacation and have some catching up to do.
I want to set formerly-unchecked input[type=checkbox] value and etc. via form.Input(). This is why fields check in Input() is deleted.