Skip to content

Commit

Permalink
👕 inp.required fix + added test to repeatables
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Tilden committed Sep 23, 2016
1 parent ad05279 commit 931b593
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/form/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const addRequired = (html, input, index) => {

if (input.required === 'save' || inp.required === 'save' || input.required === 'publish' || inp.required === 'publish') {
let level = '';
const required = input.required && inp.required;
if (inp.required !== undefined) {
level += `required--${inp.required}`;
}
Expand Down Expand Up @@ -140,7 +141,7 @@ const addRequired = (html, input, index) => {

// Add required text to label
const reLabel = new RegExp('</label>');
render = render.replace(reLabel, `<mark class="mark-${input.required}">required to ${input.required}</mark></label>`);
render = render.replace(reLabel, `<mark class="mark-${required}">required to ${required}</mark></label>`);
}
});

Expand Down
2 changes: 1 addition & 1 deletion tests/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test('Add Errors Repeatable - Pass', t => {
},
input: {
description: 'An email input with domain validation',
html: '<label for=\'{{email.id}}\'>{{email.label}}</label><input type=\'{{email.type}}\' id=\'{{email.id}}\' name=\'{{email.name}}\' value=\'{{email.value}}\' placeholder=\'{{email.placeholder}}\' />',
html: '<label for=\'{{email.id}}\'>{{email.label}} <mark class=\'mark-{{textarea.required}}\'>required to {{textarea.required}}</mark></label><input type=\'{{email.type}}\' id=\'{{email.id}}\' name=\'{{email.name}}\' value=\'{{email.value}}\' placeholder=\'{{email.placeholder}}\' />',
id: 'my-email',
inputs: [
{
Expand Down

0 comments on commit 931b593

Please sign in to comment.