Forum

Thread tagged as: Question, Problem, Forms

Getting data from form

Hello,

I was asked to create a job list page with the form underneath the page. I read through some forums and found out that this is possible but I could not figure out how to get the data submit from a form and display it as a content.

I hope you could help me with this.

Thank you!

Vaneza Mae Aumento

Vaneza Mae Aumento 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

The only option we have for UGC at the moment is the Comments app. That will give you a form that the user can fill in and the content can be redisplayed on the page.

Hi Drew,

I tried this earlier but I was having problems displaying the entries. I can see here that I can use a template but will I have to use perch:comments id values? or i can use perch:contents?

Drew McLellan

Drew McLellan 2638 points
Perch Support

It would be perch:comments for the Comments app. The tags are namespaced to the app that processes them.

Okay so how would I get the data from the form? can I use the id of the form? also how can I put an expiry on a comment?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Okay so how would I get the data from the form?

You don't. The user creates a comment with a form. You moderate it. On your page, you then display the comment.

can I use the id of the form?

No, it's not connected to the form.

also how can I put an expiry on a comment?

You'd need to filter the comments by date as you display them.

If that doesn't work for your use case then I don't have a solution, you'll have to build something with the API.

Hi Drew,

So how would i get the data to appear on the template I made?

the template looks like this

<div class="job-item col-xl-4 col-lg-4 col-md-4 col-sm-4 col-xs-12">
            <div class="job-holder">
                <div class="main-details">
                    <div class="company-logo">
                        <img src="assets/img/example-logo.png">
                    </div>
                    <h3>Job Title</h3>
                </div>
                <div class="sub-details">
                    <h4><span class="bold">Salary:</span> € 0000</h4>
                    <h4><span class="bold">Location:</span> London</h4>
                    <h4><span class="bold">Hours:</span> 10:00 AM - 5:00 PM</h4>
                    <h4><span class="bold">Description:</span> <br><span class="description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed finibus, nunc at fringilla hendrerit, eros nisi viverra nunc, elementum pellentesque nunc elit ac leo. In hac habitasse platea dictumst. Praesent gravida, urna sit amet accumsan molestie, diam justo ultricies lectus, vitae ullamcorper risus sem vitae ligula. Morbi eu tempor turpis. Quisque iaculis varius ex nec tincidunt. In hac habitasse platea dictumst. Duis magna libero, imperdiet ut laoreet eget, consequat ut tellus. </span> </h4>
                </div>
            </div>
        </div>

I also connected my form template to the cms but when i checked my entry it wasn't on the comments app.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you see your data if you use <perch:showall /> ?

I also connected my form template to the cms but when i checked my entry it wasn't on the comments app.

I don't know what that means.

Hi Drew, Finally got this to work. The only problem left is that there is an upload image field on the form and It doesn't seem to show on the page.

this is my code on the comments_form.html

 <div class="form-group">
         <label>Upload Logo</label>
          <perch:input type="image" class="form-control-file type-button" id="commentLogo" />
 </div>

on my job-list html (which is the template I use to display comments) here is my code

<div class="company-logo">
         <img src="<perch:comments type="image" class="form-control-file type-button" id="commentLogo" />">
</div>

How do I also show these custom fields on the CMS? and how can I set the status default to pending?

Thanks!

Drew McLellan

Drew McLellan 2638 points
Perch Support

There's nothing in the Comments app to handle an image upload.

Yikes! That's too bad.. hmmm is there a way to work around this?

And also the fields? how can i display the custom fields i made on the cms of the comments app as well as setting the default status to pedning?

Thanks Drew!

Drew McLellan

Drew McLellan 2638 points
Perch Support

The default status is pending. The exception is if you post while logged in.

Custom fields should be there - check your <perch:showall /> output.

Oh, okay. Got it Drew :) Thanks!

I will try that and see if the fields are shown on the admin.

Thanks ever so much Drew!

Hi Drew,

Good Morning!

I tried the <perch:showall /> tag and it did show the custom fields that I am working with but on the front-end. I wanna see these fields on the CMS and it should be editable by the administrator. Is that possible with the comments app?

Thank you!

Hi Drew,

Good Morning!

I tried the <perch:showall /> tag and it did show the custom fields that I am working with but on the front-end. I wanna see these fields on the CMS and it should be editable by the administrator. Is that possible with the comments app?

Thank you!

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, that should be possible. Just make sure they're added to the master template.

Hi Drew,

Okay. Which master template file should I place this tag? On the form template or the comment list template?

Drew McLellan

Drew McLellan 2638 points
Perch Support

The master template for a comment is comment.html.

Hi Drew,

It worked! thank you so much!