Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
Hello!

I need to create a form which gets items from a related page. Each item will have a select button and a quantity field so the user can select which items he/she wants and add their quantity.

So, how do I create this input that automatically appears linked to each related page item?

Thanks!
Hi,

If the user may select a variable number of items, you can use repeatable-regions.

Create a dropdown that is dynamically populated by the related items (using the technique described here - viewtopic.php?f=4&t=1671&p=2483&hilit=dynamic_params#p2483) and a textbox for quantity.

For adding each item, the user then can add a row, select the item and fill the quantity.

Would this help?
Thanks, KK!

The dropdown works but when I add it into the cms:form code, it suddenly disappears. I dont know why.

:(
I fixed the code and now the dropdown appears in the page.

But I have other bugs to fix. After select an option and type its quantity, I can't add another dropdown.

The option selected and the quantity typed goes right to the email, but they arent registered in the Admin.

Here's the code I have now:

- In template php:

Code: Select all
<cms:repeatable name='order_items_quantity' label="Items and Quantity">
<cms:editable
name="items"
label="Items"
opt_values='list.htm'
dynamic='opt_values'
type='dropdown'
/>
<cms:editable name="qty" type="text" label="Quantity" />
</cms:repeatable>

- In form page:

Code: Select all
<cms:pages masterpage='template.php'>
<cms:input type="dropdown" name="items" dynamic="opt_values" opt_values="<cms:embed 'list.htm' />" />
<cms:input type="text" name="qty" />
</cms:pages>
On the front end you'll have to use a 'DataBound Form' (https://docs.couchcms.com/concepts/databound-forms.html) and include your repeatable-region as a type 'bound' input.

Displaying Repeatable regions on the frontend requires also bringing in the specific JS/CSS it requires so some additional steps are needed. For those please see - viewtopic.php?f=4&t=10784#p27418

Hope it helps.
Thanks a lot, KK!

It's perfect! Now I just need to send it to user's email.

I'm using <cms:show frm_ /> but it's not working. Email is coming empty.

Thank you!
6 posts Page 1 of 1
cron