Skip to content
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

Add hiddenPrefix, hiddenSuffix crashes Rails/Rack webservers #208 #209

Closed
wants to merge 1 commit into from
Closed

Add hiddenPrefix, hiddenSuffix crashes Rails/Rack webservers #208 #209

wants to merge 1 commit into from

Conversation

harmdewit
Copy link

Adds new option hiddenPrefix that if it is set overrides hiddenSuffix

@lunks
Copy link

lunks commented Sep 10, 2013

👍

@amsul
Copy link
Owner

amsul commented Sep 12, 2013

I will look into this and merge in soon. Thanks!

@larslevie
Copy link

It's likely that for Rails the behavior you want is actually to have no prefix or suffix at all. That way Rails will use the value of the latter (hidden) input field. This is the same pattern, i.e. two inputs with identical names, with the value of the second one actually being submitted, that Rails relies on to make sure that checkboxes always submit a value (false for unchecked).

amsul added a commit that referenced this pull request Oct 12, 2013
@amsul
Copy link
Owner

amsul commented Oct 13, 2013

This has been included with v3.3

Cheers!

@amsul amsul closed this Oct 13, 2013
@mkbehbehani
Copy link

Would it be possible to contribute a note about Ruby on Rails implementation in the docs? I had the exact same issue as above in my Ruby on Rails app, getting:

Unexpected error while processing request: expected Hash (got String) for param

It would have helped me greatly to have an example or note to clear the hiddenPrefix and hiddenSuffix when using Rails:

$('.datepicker').pickadate({
    // Escape any “rule” characters with an exclamation mark (!).
    format: 'You selecte!d: dddd, mmm. dd, yyyy',
    formatSubmit: 'dddd, mmm. dd, yyyy',
    hiddenPrefix: '',
    hiddenSuffix: ''
})

@mrmarcondes
Copy link

I think that the problem isn't solved yet. When I submit my form with hiddenSuffix: ''' the component sends the same attribute twice: the first with value and the second blank.

Like this:
menu_category[menu_items_attributes][1][exhibition_date]:2013-10-02
menu_category[menu_items_attributes][1][exhibition_date]:

So Rails will save blank.

@lunks
Copy link

lunks commented Oct 28, 2013

Use a different prefix and merge them in the controller if it is present.

On Mon, Oct 28, 2013 at 3:41 PM, Marco Rojo [email protected]:

I think that the problem isn't solved yet. When I submit my form with
hiddenSuffix: ''' the component sends the same attribute twice: the first
with value and the second blank.

Like this:
menu_category[menu_items_attributes][1][exhibition_date]:2013-10-02
menu_category[menu_items_attributes][1][exhibition_date]:

So Rails will save blank.


Reply to this email directly or view it on GitHubhttps://github.com//pull/209#issuecomment-27235906
.

@mkbehbehani
Copy link

It may be helpful to note that in my configuration which is working, the input field's HTML name attribute appears below. Once it had this formatting, it worked without modification to the controller. It threw the error until I had cleared out both hiddenPrefix and hiddenSuffix:

name="appointment[requested_date]"

On Rails 4.0.0, Ruby 2.0.0p195, sqlite3 database

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants