Jump to content

How to make a dropdown a required field? $r->add_select?$r->add_select? Thanks


Recommended Posts

Hi Guys,

Hopefully an easy answer. I can make textbox data required in the shopping cart I am using but I can't figure out the syntax to make the dropdown data required. i.e if the user doesn't populate them they get a required field error.

Would love some assistance if possible, THANKS!

 

 

block_user_ad.php

 

    $r->add_textbox("feature_values_2", TEXT,"Building/Unit No.");              (WORKING)

    $r->parameters["feature_values_2"][REQUIRED] = true; (WORKING)

$r->add_textbox("feature_values_3", TEXT,"Street Address 1"); (WORKING)

    $r->parameters["feature_values_3"][REQUIRED] = true; (WORKING)

$r->add_textbox("feature_values_5", TEXT,"Town / Village"); (WORKING)

    $r->parameters["feature_values_5"][REQUIRED] = true; (WORKING)

$r->add_select("feature_values_6", TEXT, "County"); NOT WORKING :(

    ?("feature_values_6", REQUIRED, true); NOT WORKING :(

$r->add_select("feature_values_7", TEXT,"Country"); NOT WORKING :(

    $r->change_property("feature_values_7", REQUIRED, true); NOT WORKING :(

 

----------------------------------------------------------------------------------------------------

 

block_user_ad.html

 

<td>

 

<select class="text" name="feature_value_1">

<option selected value="">

<option  value="Select

">Select

<option  value="Price On Application

">Price On Application

<option  value="Price Not Applicable

">Price Not Applicable

<option  value="Contact Us For Latest Price">Contact Us For Latest Price

</select>

 

 

</td>

</tr>

 

<tr class="usual">

<td>

Building/Unit No.

  <input type="hidden" name="feature_id_2" value="">

<input type="hidden" name="group_id_2" value="1">

<input type="hidden" name="group_name_2" value="General">

<input type="hidden" name="feature_name_2" value="Building/Unit No.">

<input type="hidden" name="feature_values_2" value="">

</td>

<td>

 

 

<input class="text" type="text" name="feature_value_2" value="" size="50" maxlength="255">

 

</td>

</tr>

 

<tr class="usual">

<td>

Street Address 1

  <input type="hidden" name="feature_id_3" value="">

<input type="hidden" name="group_id_3" value="1">

<input type="hidden" name="group_name_3" value="General">

<input type="hidden" name="feature_name_3" value="Street Address 1">

<input type="hidden" name="feature_values_3" value="">

</td>

<td>

 

 

<input class="text" type="text" name="feature_value_3" value="" size="50" maxlength="255">

 

</td>

</tr>

 

<tr class="usual">

<td>

Street Address 2

  <input type="hidden" name="feature_id_4" value="">

<input type="hidden" name="group_id_4" value="1">

<input type="hidden" name="group_name_4" value="General">

<input type="hidden" name="feature_name_4" value="Street Address 2">

<input type="hidden" name="feature_values_4" value="">

</td>

<td>

 

 

<input class="text" type="text" name="feature_value_4" value="" size="50" maxlength="255">

 

</td>

</tr>

 

<tr class="usual">

<td>

Town / Village

  <input type="hidden" name="feature_id_5" value="">

<input type="hidden" name="group_id_5" value="1">

<input type="hidden" name="group_name_5" value="General">

<input type="hidden" name="feature_name_5" value="Town / Village">

<input type="hidden" name="feature_values_5" value="">

</td>

<td>

 

 

<input class="text" type="text" name="feature_value_5" value="" size="50" maxlength="255">

 

</td>

</tr>

 

<tr class="usual">

<td>

County

  <input type="hidden" name="feature_id_6" value="">

<input type="hidden" name="group_id_6" value="1">

<input type="hidden" name="group_name_6" value="General">

<input type="hidden" name="feature_name_6" value="County">

<input type="hidden" name="feature_values_6" value="Cork">

</td>

<td>

 

<select class="text" name="feature_value_6">

<option selected value="">

<option  value="Cork">Cork

</select>

 

 

</td>

</tr>

 

<tr class="usual">

<td>

Country

  <input type="hidden" name="feature_id_7" value="">

<input type="hidden" name="group_id_7" value="1">

<input type="hidden" name="group_name_7" value="General">

<input type="hidden" name="feature_name_7" value="Country">

<input type="hidden" name="feature_values_7" value="Ireland">

</td>

<td>

 

<select class="text" name="feature_value_7">

<option selected value="">

<option  value="Ireland">Ireland

</select>

 

 

</td>

</tr>

I don't know what application you're using how this $r object is form OR what the class looks like.  But going by the pattern from the working ones use this for the last 4 that aren't working...

 

   $r->add_textbox("feature_values_6", TEXT, "County");
   $r->parameters["feature_values_6"][REQUIRED] = true;  
   $r->add_textbox("feature_values_7", TEXT,"Ireland");    
   $r->parameters["feature_values_7"][REQUIRED] = true;   

Thanks a million! Got it working. Edited ur code a little _value instead of _values & it worked

$r->add_textbox("feature_value_6", TEXT, "County");

  $r->parameters["feature_value_6"][REQUIRED] = true; 

  $r->add_textbox("feature_value_7", TEXT,"Country");   

  $r->parameters["feature_value_7"][REQUIRED] = true;

 

Thanks again! :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.