4 of 6
4
Checkboxes
Posted: 16 April 2007 12:36 PM   [ Ignore ]   [ # 55 ]  
Grad Student
Rank
Total Posts:  90
Joined  02-26-2007

ohhhhhhhh.. doh!!!!.

thanks brian.

so how would i make a checkbox for the member registration form?

Profile
 
 
Posted: 16 April 2007 08:15 PM   [ Ignore ]   [ # 56 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  785
Joined  07-18-2006
neweras - 16 April 2007 12:36 PM

ohhhhhhhh.. doh!!!!.

thanks brian.

so how would i make a checkbox for the member registration form?

You can manually build a form that registers people - all you need to do is include:

<input type="hidden" name="ACT" value="7" />

in the form.  You’ll probably want to include a few other hidden fields.  Here’s a manual registration form I’m currently using:

<h1>Member Registration</h1>
            <
p>Please fill out the form below. All fields are required. After registering you will receive a confirmation email - follow the link in that email to complete the registration process.</p>        
            <
form id='register_member_form' method="post" action="">
            <
fieldset>
                <
input type="hidden" name="XID" value="" />
                 <
input type="hidden" name="ACT" value="7" />
                <
input type="hidden" name="mbase" value="{path=pages/thank_you/register}" />
                <
input type="hidden" name="RET" value="{path=pages/thank_you/register}" />
                <
input type="hidden" name="FROM" value="" />
                
                <
label for="username"><span class="required">*</span> Username</label>
                <
input class="inputMedium" type="text" name="username" value="" maxlength="32" />

                <
label for="password"><span class="required">*</span> Password</label>
                <
input class="inputMedium" type="password" name="password" value="" maxlength="32" />
                
                <
label for="password"><span class="required">*</span> Password Confirm</label>
                <
input class="inputMedium" type="password" name="password_confirm" value="" maxlength="32" />
                <
label for="password"><span class="required">*</span> Screen Name</label>
                <
input class="inputMedium" type="text" name="screen_name" value="" maxlength="32" />
                <
label for="password"><span class="required">*</span> Email Address</label>
                <
input class="inputMedium" type="text" name="email" value="" maxlength="120" />
                <
label for="password"><span class="required">*</span> Company Password</label>
                <
input class="inputMedium" type="text" name="m_field_id_1" value="" maxlength="32" />
                
                <
label for="rules"><span class="required">*</span> Terms of Service</label>
                <
textarea name='rules' class='textShort' readonly>All messages posted at this site express the views of the author, and do not necessarily reflect the views of the owners and administrators of this site.

By registering at this site you agree not to post anything that is obscene, vulgar, slanderous, hateful, threatening, or that violate any laws. We will permanently ban all users who do so.

The VBSR forums are an information and networking resource for members. We ask that you not post any advertisements, sales, discounts, solicitations, promotions, or any other content to advance your business. We reserve the right to remove any messages that we feel falls under the above categories, and the right to remove, edit, or move any messages for any reason.</textarea>    
                <
ul>
                    <
li><input type='checkbox' name='accept_terms' value='y' />I agree to the terms of service.</li>
                </
ul>                
            </
fieldset>
            <
input class="button" type="image" name="submit" src="/css/images/button_register.gif" />
            </
form>

Profile
 
 
Posted: 20 April 2007 01:35 AM   [ Ignore ]   [ # 57 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  361
Joined  01-13-2004

Could someone (especially Brian M since he said he had it working) show a code sample for how to display checkboxes with a stand-alone entry form?  Mark I love your work, though it is a shame that your doc page doesn’t seem to actually contain any docs.  Maybe We could set up wiki pages for your extensions?

 Signature 

———-
1.6.4— Build: 200800808

Profile
 
 
Posted: 20 April 2007 07:33 AM   [ Ignore ]   [ # 58 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  785
Joined  07-18-2006
UltraBob - 20 April 2007 01:35 AM

Could someone (especially Brian M since he said he had it working) show a code sample for how to display checkboxes with a stand-alone entry form?  Mark I love your work, though it is a shame that your doc page doesn’t seem to actually contain any docs.  Maybe We could set up wiki pages for your extensions?

Ultrabob - I’m manually creating my SAEFs and just putting in checkboxes…  Here’s a snippet (I can post the whole form if it would help):

<li><input class="checkbox" type="checkbox" name="options[]" value="Learn more about joining a committee" />Learn more about joining a committee</li>
<
li><input class="checkbox" type="checkbox" name="options[]" value="Sponsor an event" />Sponsor an event</li>
<
li><input class="checkbox" type="checkbox" name="options[]" value="Learn about upcoming VBSR events" />Learn about upcoming VBSR events</li>

Just make sure to have [] after your field names, and you should be all set…

Profile
 
 
Posted: 05 May 2007 09:18 AM   [ Ignore ]   [ # 59 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  599
Joined  12-10-2006

Does anyone know if it’s possible to change the delimiter on the output of the checkbox extension? Currently it outputs as: Blah, Blah, Blah, Blah. I’d like to change the commas into pipes (|), but only in a specific instance (I don’t want to hard code it for everything). I guess I could use php if I need to…

Thanks

Profile
 
 
Posted: 05 May 2007 09:44 AM   [ Ignore ]   [ # 60 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1194
Joined  01-05-2006

you should be able to use the separator=”” attribute and use whatever you need.

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 18 May 2007 09:48 AM   [ Ignore ]   [ # 61 ]  
Grad Student
Rank
Total Posts:  76
Joined  09-26-2005

Has anybody had any success getting this to work in a standalone EDIT form?

Thanks in advance,
Ken

Profile
 
 
Posted: 18 May 2007 09:58 AM   [ Ignore ]   [ # 62 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  785
Joined  07-18-2006

Yep it works pretty much right ‘out of the box’ in edit SAEFs.

Profile
 
 
Posted: 18 May 2007 10:46 AM   [ Ignore ]   [ # 63 ]  
Grad Student
Rank
Total Posts:  76
Joined  09-26-2005

Thanks Brian. I can’t seem to get the values to display in the edit form. Here is what I have for the ENTRY form, which works fine:

<p><b>Open to</b><br />
<
input type="checkbox" name="field_id_350[]" value="Public" />Public<br />
<
input type="checkbox" name="field_id_350[]" value="Practitioners" />Practitioners<br />
<
input type="checkbox" name="field_id_350[]" value="Trainees" />Trainees<br />

The EDIT version doesn’t work. I’ve tried:

<p><b>Open to</b><br />
<
input type="checkbox" name="field_id_350[]" id="public" value="field_id_350[]" />Public<br />
<
input type="checkbox" name="field_id_350[]" id="practitioners" value="field_id_350[]" />Practitioners<br />
<
input type="checkbox" name="field_id_350[]" id="trainees" value="field_id_350[]" />Trainees</p>

and

<p><b>Open to</b><br />
<
input type="checkbox" name="field_id_350[]" id="public" value="Public" {checked} />Public<br />
<
input type="checkbox" name="field_id_350[]" id="practitioners" value="Practitioners" {checked} />Practitioners<br />
<
input type="checkbox" name="field_id_350[]" id="trainees" value="Trainees" {checked} />Trainees</p>

and

<p><b>Open to</b><br />
<
input type="checkbox" name="field_id_350[]" id="field_id_350[]" value="field_id_350[]" {checked} />Public<br />
<
input type="checkbox" name="field_id_350[]" id="field_id_350[]" value="field_id_350[]" {checked} />Practitioners<br />
<
input type="checkbox" name="field_id_350[]" id="field_id_350[]" value="field_id_350[]" {checked} />Trainees</p>

In each case, all checkboxes in the EDIT form are blank.

Any help?

Thanks again,
Ken

Profile
 
 
Posted: 18 May 2007 10:59 AM   [ Ignore ]   [ # 64 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  785
Joined  07-18-2006

Ken - you’ll need to use SolSpace’s Form Helper plugin, and then you’ll end up with code like so for your values:

value="{exp:form_helper:field_parser}{field_id_40}{/exp:form_helper:field_parser}"

EDIT: or you can do it using PHP and the $DB class if you prefer…

Profile
 
 
Posted: 18 May 2007 11:51 AM   [ Ignore ]   [ # 65 ]  
Grad Student
Rank
Total Posts:  76
Joined  09-26-2005

Brian, your quick responses are much appreciated! A couple more samples of code I’ve tried that are not working:

<p><b>Open to</b><br />
<
input type="checkbox" name="field_id_350[]" value="{exp:form_helper:field_parser}{field_id_350}{/exp:form_helper:field_parser}" />Public<br />
<
input type="checkbox" name="field_id_350[]" value="{exp:form_helper:field_parser}{field_id_350}{/exp:form_helper:field_parser}" />Practitioners<br />
<
input type="checkbox" name="field_id_350[]" value="{exp:form_helper:field_parser}{field_id_350}{/exp:form_helper:field_parser}" />Trainees</p>

and this one, after reading the form helper docs again, using field_grabber instead of field_parser, since my understanding is that the field_parser is to remove or grab the formatting (XHTML, BR or None), and the checkbox does not have field formatting:

<p><b>Open to</b><br />
<
input type="checkbox" name="field_id_350[]" value="{exp:form_helper:field_grabber field_name='field_id_350'} value="{field_id_350}" />Public<br />
<input type="
checkbox" name="field_id_350[]" value="{exp:form_helper:field_grabber field_name='field_id_350'} value="{field_id_350}" />Practitioners<br />
<
input type="checkbox" name="field_id_350[]" value="{exp:form_helper:field_grabber field_name='field_id_350'} value="{field_id_350}" />Trainees</p>

I also tried a version of the above with both field_grabber and field_parser, per the Solspace docs, with no luck.

(I don’t have the coding experience to try the PHP and $DB class method you mentioned)  red face

Profile
 
 
Posted: 18 May 2007 12:01 PM   [ Ignore ]   [ # 66 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  785
Joined  07-18-2006

Hmm - can you post (or attach) the entire form code?

Profile
 
 
Posted: 18 May 2007 12:46 PM   [ Ignore ]   [ # 67 ]  
Grad Student
Rank
Total Posts:  76
Joined  09-26-2005

No problem…. checkboxes start around line 84….

File Attachments
event_edit.txt  (File Size: 7KB - Downloads: 90)
Profile
 
 
Posted: 18 May 2007 02:32 PM   [ Ignore ]   [ # 68 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  785
Joined  07-18-2006

I just realized I’m using PHP to do it in my templates (using Field Helper for other forms not using checkboxes). I’m not sure if this will work, but try this:

<input type="checkbox" name="field_id_350[]" value="Public" {exp:form_helper:field_parser}{if field_id_350 == 'Public'} checked="checked"{/if}{/exp:form_helper:field_parser} />Public<br />

If that doesn’t work I’ll help you set it up using PHP.

Profile
 
 
Posted: 25 May 2007 11:05 AM   [ Ignore ]   [ # 69 ]  
Grad Student
Rank
Total Posts:  76
Joined  09-26-2005

Hi Mark,

Apologies for the delay getting back. I’ve been occupied with another project.

I tried the code you sent above… still didn’t work.

I’m thinking I should rethink the way we’re setting this up, but I’m interested in seeing how you would do it with PHP as well.

Thanks for all the help,
Ken

Profile
 
 
Posted: 20 June 2007 09:45 AM   [ Ignore ]   [ # 70 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  324
Joined  03-07-2006

Hi all, I’m not sure that I’m using this properly…

I’m hoping to provide 6 checkboxes in the publish form in a custom field called {stockists-offers}

The options are:

Fabrics
Wallpapers
Paints
Paint-Sample-Pots
Trimmings
Furniture

I want a list item containing an icon to appear IF the box has been ticked so I produced this code, it seems to work for Fabrics (the first item) but nothing else :(

<ul class="offers">
        
{if stockist-offers == "Fabrics"}<li class="fabric-icon">Fabrics</li>{/if}
        {if stockist
-offers == "Wallpapers"}<li class="wallpaper-icon">Wallpapers</li>{/if}
        {if stockist
-offers == "Paints"}<li class="paint-icon">Paints</li>{/if}
        {if stockist
-offers == "Paint-Sample-Pots"}<li class="sample-icon">Paint Sample Pots</li>{/if}
        {if stockist
-offers == "Trimmings"}<li class="trimmings-icon">Trimmings</li>{/if}
        {if stockist
-offers == "Furniture"}<li class="furniture-icon">Furniture</li>{/if}
    
</ul>

 Signature 

· Confused… but happy ·

Profile
 
 
Posted: 21 June 2007 07:38 AM   [ Ignore ]   [ # 71 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1194
Joined  01-05-2006

That’s because in the database it’s stored as:

Fabrics
Wallpapers

So if you select more than one item it won’t work because “Wallpapers != Fabrics\nWallpapers”

You could use PHP on output to get around this:

<?php
$stocklist_offers
= <<<EOT
{stocklist-offers}
EOT;?>
<ul class="offers">
    
<?php if(strpos($stockist_offers, "Fabrics")): ?><li class="fabric-icon">Fabrics</li><?php endif; ?>
    <?php
if(strpos($stockist_offers, "Wallpapers")): ?><li class="wallpaper-icon">Wallpapers</li><?php endif; ?>
    <?php
if(strpos($stockist_offers, "Paints")): ?><li class="paint-icon">Paints</li><?php endif; ?>
    <?php
if(strpos($stockist_offers, "Paint-Sample-Pots")): ?><li class="sample-icon">Paint Sample Pots</li><?php endif; ?>
    <?php
if(strpos($stockist_offers, "Trimmings")): ?><li class="trimmings-icon">Trimmings</li><?php endif; ?>
    <?php
if(strpos($stockist_offers, "Furniture")): ?><li class="furniture-icon">Furniture</li><?php endif; ?>
</ul>

That’s sort of off the top of my head so there may be a syntax error in there or a typo, but it should get you started

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 21 June 2007 07:52 AM   [ Ignore ]   [ # 72 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  324
Joined  03-07-2006

Thanks Mark, I think there may be an error somewhere as the page is coming up blank. Unfortunately I don’t know any php so I’m stumped as what the problem could be :/

Here is most of the page code if you can see anything quickly wrong with it?

<div id="content">

<
h2>{page}</h2>


<
h3 id="sub-heading">{countries}</h3>

{exp:weblog:category_heading weblog="{section}"}
<h4>{category_name}</h4>
{/exp:weblog:category_heading}

<ol id="stockistslist">

{exp:weblog:entries weblog="stockists_{segment_3}" paginate="bottom" limit="9"}


<li>
<
dl>
<
dt>{title}</dt>
<
dd>{stockist-address}</dd>
<
dd><strong>Tel: </strong>{stockist-phone}</dd>
<
dd><strong>Fax: </strong>{stockist-fax}</dd>
<
dd><strong>Email: </strong>{stockist-email}</dd>
<
dd><strong>Website: </strong>{if stockist-website}<a href="{exp:html_strip}{stockist-website}{/exp:html_strip}" title="Visit {title}'s website">Click here</a> {if:else} N/A{/if}</dd>
<
dd><strong>Map and Directions: </strong><a href="#">Click here</a></dd>
<
dd>

    
<?php
    $stocklist_offers
= <<<EOT
    {stocklist-offers}
    EOT;?>
    <ul class="offers">
        <?php if(strpos($stockist_offers, "Fabrics")): ?><li class="fabric-icon">Fabrics</li><?php endif; ?>
        <?php if(strpos($stockist_offers, "Wallpapers")): ?><li class="wallpaper-icon">Wallpapers</li><?php endif; ?>
        <?php if(strpos($stockist_offers, "Paints")): ?><li class="paint-icon">Paints</li><?php endif; ?>
        <?php if(strpos($stockist_offers, "Paint-Sample-Pots")): ?><li class="sample-icon">Paint Sample Pots</li><?php endif; ?>
        <?php if(strpos($stockist_offers, "Trimmings")): ?><li class="trimmings-icon">Trimmings</li><?php endif; ?>
        <?php if(strpos($stockist_offers, "Furniture")): ?><li class="furniture-icon">Furniture</li><?php endif; ?>
    </ul>
    
</dd>
</dl>
</li>


{/exp:weblog:entries}

</ol>


</div><!-- content -->


</div><!-- wrapper -->

{embed="includes/footer"}

 Signature 

· Confused… but happy ·

Profile
 
 
   
4 of 6
4
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 66457 Total Logged-in Users: 68
Total Topics: 84841 Total Anonymous Users: 18
Total Replies: 455264 Total Guests: 222
Total Posts: 540105    
Members ( View Memberlist )
Newest Members:  AtosheviboyjbcobbsOut_ThereChrisClowerstevelovePhoenix FirstgoyoqshimshimSchaapy