required select list problem

14 years 10 months ago #101383 by supplymetal
Replied by supplymetal on topic Re:required select list problem
I'm trying to find a way to create a drop down list of US states and it led me to this thread... I am to understand the list has to be created manually? Is there a bug that prevents this method for creating such a drop down exist?

I have purchased a license for CB Subs and the list is needed for registration.

Thank you!

Post edited by: supplymetal, at: 2009/06/08 12:22

Please Log in to join the conversation.

14 years 10 months ago #101464 by nant
Replied by nant on topic Re:required select list problem
supplymetal wrote:

I'm trying to find a way to create a drop down list of US states and it led me to this thread... I am to understand the list has to be created manually? Is there a bug that prevents this method for creating such a drop down exist?

I have purchased a license for CB Subs and the list is needed for registration.

Thank you!

Post edited by: supplymetal, at: 2009/06/08 12:22


You can follow example of this article:

www.joomlapolis.com/content/view/208/37/

and make it work for states case.

Please Log in to join the conversation.

14 years 3 months ago #120829 by beat
Replied by beat on topic Re:required select list problem
The original issue is fixed for upcoming CB 1.2.2.

Here the fix in diff-style:

[code:1]+++ administrator/components/com_comprofiler/comprofiler.class.php
@@ -335,11 +335,11 @@
function selectList( &$arr, $tag_name, $tag_attribs, $key, $text, $selected, $required = 0, $htmlspecialcharText = true ) {
reset( $arr );
$id_name = moscomprofilerHTML::htmlId( $tag_name );
$html = "\n"
. '<select name="' . htmlspecialchars( $tag_name ) . '" id="' . htmlspecialchars( $id_name ) . '" ' . $tag_attribs . '>';
- $addBlank = ( ( ! $required ) && ! ( isset( $arr[0] ) && $arr[0]->$key == '' ) );
+ $addBlank = ( ( ( ! $required ) || ( is_array( $selected ) ? ( count( $selected ) == 0 ) : ( $selected == '' ) ) ) && ! ( isset( $arr[0] ) && $arr[0]->$key == '' ) );
if ( $addBlank ) {
$html .= "\n\t<option value=\"\"> </option>";
}


+++ administrator/components/com_comprofiler/plugin.class.php
@@ -1558,11 +1558,15 @@
$value->text = ( $reason == 'search' ? ( $noneValue ? _UE_NONE : _UE_NO_PREFERENCE ) : _UE_NO_INDICATION );
return $value;
}
function _explodeCBvaluesToObj( $value ) {
if ( ! is_array( $value ) ) {
- $value = explode( '|*|', $value );
+ if ( ( $value === '' ) || is_null( $value ) ) {
+ $value = array();
+ } else {
+ $value = explode( '|*|', $value );
+ }
}
$objArr = array();
foreach( $value as $k => $kv ) {
$objArr[$k]->value = $kv;
$objArr[$k]->text = $kv;
[/code:1]

Edit: (fix format posted is unified diff: remove lines with - and replace by lines with + at begin).

Post edited by: beat, at: 2010/01/05 16:29

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.270 seconds

Facebook Twitter LinkedIn