more useful error message where there is nothing to choose from
This commit is contained in:
parent
0f6b5be6e3
commit
d0f526ec86
@ -716,8 +716,11 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
|
||||
}
|
||||
|
||||
$choices = false;
|
||||
$zero_options = false;
|
||||
foreach ( $form[ 'eventslots' ] as $eventpart_id => $eventpart_form ) {
|
||||
if ( count( $eventpart_form[ '#options' ] ) == 1 ) {
|
||||
if ( count( $eventpart_form[ '#options' ] ) == 0 ) {
|
||||
$zero_options = true;
|
||||
} else if ( count( $eventpart_form[ '#options' ] ) == 1 ) {
|
||||
foreach ( $eventpart_form[ '#options' ] as $option_key => $option_value )
|
||||
$form[ 'eventslots' ][ $eventpart_id ][ '#default_value' ] = $option_key;
|
||||
} else {
|
||||
@ -725,6 +728,10 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
|
||||
}
|
||||
}
|
||||
|
||||
if ( $zero_options ) {
|
||||
drupal_set_message(t('Unfortunately it looks like some of the choices for this type of ticket are completely sold out.'), 'error', FALSE);
|
||||
}
|
||||
|
||||
if ( $choices ) {
|
||||
$form[ 'ticket_for_persons' ][ '#type' ] = 'radios';
|
||||
if ( count( $form[ 'ticket_for_persons' ][ '#options' ] ) == 1 ) {
|
||||
@ -752,6 +759,11 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
|
||||
'#submit' => array( 'fulcrm_shoppingcart_buy_eventbookingtype_form_submit' ),
|
||||
);
|
||||
|
||||
if ( $zero_options ) {
|
||||
$form[ 'actions' ][ 'submit' ][ '#disabled' ] = true;
|
||||
$form[ 'actions' ][ 'submit' ][ '#value' ] = t('Sold Out');
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user