Add dynamic fields within a custom block
Permalink
I'm thinking of building a simple question and answer block where user will be able to add a question and answer. How would I set this up so that multiple question and answers could be added within the same block.
I'm guessing it would need some sort of javascript add/delete functionality. Not sure how the db schema would be set up for this?
Once all question/answers have been added the user would save the block and they would appear on the page as per the view.php file.
Is there anything similar out there I could reference for free?
I'm guessing it would need some sort of javascript add/delete functionality. Not sure how the db schema would be set up for this?
Once all question/answers have been added the user would save the block and they would appear on the page as per the view.php file.
Is there anything similar out there I could reference for free?
The need to add multiple items in a block would be so that I could generate the following code:
So that all question/answers are encapsulated in the same parent div in this case the <ul>.
Also it takes the hassle out of having to add a new block for every single question/answer.
<ul class="accordion"> <li class="accordion-item"> <h2>Question</h2> <p>Answer</p> </li> <li class="accordion-item"> <h2>Question</h2> <p>Answer</p> </li> <li class="accordion-item"> <h2>Question</h2> <p>Answer</p> </li> </ul>
So that all question/answers are encapsulated in the same parent div in this case the <ul>.
Also it takes the hassle out of having to add a new block for every single question/answer.
First see the documentation about how to create custom block from this linkhttp://www.concrete5.org/documentation/developers/blocks/understand...
Then you can follow wonderful how-to by JohntheFishhttp://www.concrete5.org/documentation/how-tos/designers/create-a-f...
You can see the blow link of my forum post. I already did the task like this. But I did that in my single page not using block.
http://www.concrete5.org/developers/pro-accounts/community-leaders-...
And you can follow concrete5 core form block for reference
Then you can follow wonderful how-to by JohntheFishhttp://www.concrete5.org/documentation/how-tos/designers/create-a-f...
You can see the blow link of my forum post. I already did the task like this. But I did that in my single page not using block.
http://www.concrete5.org/developers/pro-accounts/community-leaders-...
And you can follow concrete5 core form block for reference
http://www.concrete5.org/marketplace/addons/example-faq/...
May I ask why you'd need to add multiple items in one block? Could you use the block above and just add as many FAQ blocks as you'd need?