I am filing a form with data. I would like to add another one or more set of fields in the same form and then
save it all in one step.
for example:
in my views/../tmpl/myfile.php
I put this script (adds input file field):
<script language="javascript">
fields = 0;
function addInput() {
if (fields != 3) {
document.getElementById('entireform').innerHTML += "<input type='file' value='' name='fields[]' /><br />";
fields += 1;
} else {
document.getElementById('entireform').innerHTML += "<br />Only 3 upload fields allowed.";
document.form.add.disabled=true;
}
}
</script>
.
.
.
this continues with native j-cook code
<table class="admintable">
<tr>
<td align="right" class="key">
<label for="entry_date">
<?php echo JText::_( "TRAINING_FIELD_ENTRY_DATE" ); ?> :
</label>
</td>
<td>
<?php echo JDom::_('html.form.input.calendar', array(
'dataKey' => 'entry_date',
'dataObject' => $this->xyz,
'dateFormat' => "%Y-%m-%d",
'required' => true,
'validatorMsgRequired' => "VALIDATOR_ENTER_THE_DATE",
'validatorHandler' => "datetime",
'validatorMsgInfo' => "VALIDATOR_ENTER_OR_EDIT_THE_DATE"
));
?>
</td>
The javascript script above is called by:
<input type="button" onclick="addInput()" name="add" value="Add another field" />
So the question is whether it is feasible in this way to duplicate the fields?
Need to replace:
<input type='file' value='' name='fields[]' /><br />
with
JDom::_('html.form.input.calendar'.....