Skip to content

Support for autogenerated ID for formbuilder - #150

Open
cardil wants to merge 7 commits into
quirkey:masterfrom
cardil:master
Open

Support for autogenerated ID for formbuilder#150
cardil wants to merge 7 commits into
quirkey:masterfrom
cardil:master

Conversation

@cardil

@cardil cardil commented Jul 25, 2012

Copy link
Copy Markdown

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

cardil commented Feb 19, 2013

Copy link
Copy Markdown
Author

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

cardil commented Nov 26, 2015

Copy link
Copy Markdown
Author

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

@piecioshka

Copy link
Copy Markdown
Contributor

@quirkey ping

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.

3 participants