This is done using JavaScript, see below, just paste this in a
blank .php file and check it out.
You could also use the html / form helper to create the input field
string once, but if you need to generate field names, this should
likely go into your java script code, unless you use AJAX to have the
server generate it.
<html>
<head>
<script type="text/javascript">
function addNewInput(attrString) {
inputList = document.getElementById('inputList');
if (inputList) {
inputList.innerHTML += '<p><input ' + attrString + '/></p>';
}
}
</script>
</head>
<body>
<div id="inputList">
<p><input type="file"/></p>
</div>
<p>
<?
$attributes = htmlentities('type="file" name="data[Model][field]"');
?>
<a href="" onClick="addNewInput('<?=$attributes?>');return false;">add
input field</a>
</p>
</body>
Best,
JP
On 30 Jan., 13:11, Flawe <[EMAIL PROTECTED]> wrote:
> I was wondering how one could achieve the same effect as Facebook
> where they have a "add another field" link bellow a form which lets
> the user insert a new input field, allowing him to submit several
> entries?
>
> The new input field should be of the same type (i.e. affect the same
> model), I just want to be able to submit any number of entries,
> specified by the user himself.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---