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

Form Builder: can't get the value of disabled fields #368

Closed
c-frater opened this Issue Jan 9, 2017 · 0 comments

Comments

Projects
None yet
2 participants
@c-frater
Copy link
Contributor

c-frater commented Jan 9, 2017

Context

Sometimes it makes sense to have a disabled field that the user can see but can't edit (for instance when passing data from one form to another). When getting the data from a form with disabled fields, those fields are returned as undefined, regardless of their value.

This does not tie up with hidden (as no key is returned for hidden fields)

Test Case:

const formDiv = hx.div()
const form = new hx.Form(formDiv.node())

form.addText('Text', {key: 'bob'})
  .addText('Steve')
  .addText('Dave')

form.data({
  'bob': '123',
  'Steve': '456',
  'Dave': '789'
})


form.disabled('bob', true)
form.disabled('Steve', true)
form.hidden('Dave', true)

hx.select('body').clear()
  .add(formDiv)

console.log(form.data())

Expected Behavior

form.data() should return

{ bob: '000', Steve: '456' }

Actual Behavior

form.data() returns

{ bob: undefined, Steve: undefined }

Possible Fix

As part of #156 the logic for disabled was made to mirror hidden fields. I believe in this case it was done incorrectly and updating the value method to return the value of disabled fields makes the most sense.

Your Environment

  • Hexagon Version: 1.9.0

@c-frater c-frater added the Bug label Jan 9, 2017

@c-frater c-frater self-assigned this Jan 9, 2017

@c-frater c-frater added the In Progress label Jan 9, 2017

@c-frater c-frater referenced this issue Jan 9, 2017

Merged

#368 Form Builder disabled bugfix #369

6 of 6 tasks complete

@c-frater c-frater added In Review and removed In Progress labels Jan 9, 2017

@jmsmyth jmsmyth closed this in #369 Jan 9, 2017

jmsmyth added a commit that referenced this issue Jan 9, 2017

Merge pull request #369 from ocadotechnology/#368-form-builder-disabl…
…ed-bugfix

#368 Form Builder disabled bugfix

@jmsmyth jmsmyth removed the In Review label Jan 9, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment