w2ui is ignoring the value on the input tag.
How do I get it to use the value?
It reads the selects just fine.
<div id="form" style="width: 750px;">
<div class="w2ui-page page-0">
<div class="w2ui-field">
<label>First Name:</label>
<div>
<input name="first_name" type="text" value="John" />
</div>
</div>
</div>
<div class="w2ui-buttons">
<button class="w2ui-btn" name="reset">Reset</button>
<button class="w2ui-btn" name="save">Save</button>
</div>
</div>
$(function() {
$('#form').w2form({
name: 'form',
url: 'server/post',
fields: [
{ field: 'first_name', type: 'text', required: true }
],
actions: {
reset: function() {
this.clear();
},
save: function() {
this.save();
}
}
});
});
If I have to write JavaScript. How would I access the fields?
You can access the value of the input with form.record
.
In your case w2ui.form.record.first_name
(where form
is the name of your w2form).
In your save event you can access the record with this.record
, e.g.:
save: function() {
console.log(this.record);
console.log(this.record.first_name);
this.save();
}