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

Support for autogenerated ID for formbuilder #150

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

cardil
Copy link

@cardil cardil commented Jul 25, 2012

Hello I've added support for automated generation of form element IDs (they are required to work properly with label element). For example:

var item = {
    name: 'My Item',
    price: '$25.50',
    meta: {
        id: '123'
    }
};
var form = new Sammy.FormBuilder('item', item);
form.text('name');
//=> <input type="text" name="item[name]" value="My Item" class="item-name" id="item-name-31005" />
form.label('name', 'Enter name:');
//=> <label for="item-name-31005">Enter name:</label>

This integer from example: 31005 is generated from class-name field and it is there to be sure not to overlap with some other element ID on the webpage (ID should be unique)

You may also notice that I've changed apostrophe with quotation for HTML elements witch is more proper. It was:

<div class='test'>test</div>

and it is now:

<div class="test">test</div>

I've also modified unit tests to refer those changes

@cardil
Copy link
Author

cardil commented Feb 19, 2013

I've pulled latest changes from sammy v0.7.4 and added my fixes to form.js

…tion.hash` instead of `location` witch previouslly couses a redirect to debug hosted.html file; corrected tests for form builder
@cardil
Copy link
Author

cardil commented Nov 26, 2015

Hello that have been a while. 3 years almost. Would you merge it? Is it still being developed?

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

Successfully merging this pull request may close these issues.

2 participants