I have a Joomla component for managing workshops, called com_workshops with its corresponding table, jos_workshops.
Then I have the core com_users
component, with its jos_users
table.
I have a link table, jos_works_users
in order to associate users to workshops (N,N).
I know how to add a form field type="user" so I can select from the users modal view a user.
But I would like the form to be able to add as many form field types like this one as I
want, and to remove them dynamically. I'm thinking about
jQuery (append(), clone(), remove() functions)
But don't know if it's possible inside a Joomla! form, and how to do it.
I have made a similar field, although I used mootools. If I were you I'd create a new field type ( Joomla docs ) and add some javascript to the page using JHTML::script(). You need to use a input name like jform[userids][] so that the browsers can pass a array of user ids.
My case was not exactly like yours, but this is pretty much how I did it:
My HTML looked like this (note that it has two text fields per row):
<div id="ingredientList1">
<div class="ingredient-row">
<div class="delete"></div>
<input type="text" class="amountField" style="display: block; " name="jform[ingredientAmounts][]">
<input type="text" class="nameField" style="display: block; " name="jform[ingredients][]">
</div>
<div class="ingredient-row">
<div class="delete"></div>
<input type="text" class="amountField" style="display: block; " name="jform[ingredientAmounts][]">
<input type="text" class="nameField" style="display: block; " name="jform[ingredients][]">
</div>
<div class="ingredient-row">
<div class="add"></div>
<input type="text" class="amountField" style="display: none; ">
<input type="text" class="nameField" style="display: none; ">
</div>
</div>
Your javascript should:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.