Forum

Thread tagged as: Problem, Forms

Setting checkbox to checked in Form App

Hi,

I have added the Mailchimp app to my contact form to give users the option to join mailinglist. I have this working well but the problem I have is setting the checkbox to checked on page load. I can't see what I am doing wrong, I saw on perch_content there is default field but it wasn't mentioned in the form docs.

I have this for the input field, form example

<perch:input type="checkbox" id="confirm" label="mailinglist" checked="checked" value="1" mailer="confirm_subscribe" />
Andrew Cetnarskyj

Andrew Cetnarskyj 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Try

value="1" default="1"

Just got a chance to try it:

I have this in the form html template

<perch:input type="checkbox" id="confirm" label="mailinglist" checked="checked" value="1" default="1" mailer="confirm_subscribe" />

It writes out this, the checkbox isn't selected

<input id="form1_confirm" name="confirm" value="1" type="checkbox">

I am running the latest version of perch and the mailchimp app.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, I'll look into it.

Great thanks. If I need to update part of the core to fix it I don't mind getting editing the files I need to.

Hi Drew,

I noticed there was a form app update. Did you managed to fix this issue in there?

Drew McLellan

Drew McLellan 2638 points
Perch Support

It's not a Forms app issue. The Forms app is one way of processing a submitted form. It doesn't have anything to do with the display of forms.

Ok, I thought perch:input was related to the form app as that is where the issue seems to be.

Drew McLellan

Drew McLellan 2638 points
Perch Support

No, perch:input is a template tag for creating a form input.

The Forms app is a specific tool for collecting form responses and emailing or storing the result. The Forms app doesn't display forms - it's for processing some types of form submission.

Thanks for the clarification on what is what.

Drew McLellan said:

Ok, I'll look into it.

Going back to your last reply is there a solution to the issue with setting the default to checked?

Drew McLellan

Drew McLellan 2638 points
Perch Support

No, but it is logged.

thanks

The <perch:input> checkboxes on my forms default to checked and I do not know how to default them to be unchecked. (I've tried variations on all the methods listed in this thread.) Is this a related issue to what's written here? Do you have any suggestions?

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Jason, if you have a problem you need to start a new thread including your template code.

Drew McLellan said:

No, but it is logged.

Was this bug fixed in 2.7.4 update?

Drew McLellan

Drew McLellan 2638 points
Perch Support

I don't think it's changed in 2.7.4. I'm not yet fully convinced that it's a bug, but it's logged to look into.