You could do this using javascript rather than validation.
E.g. Create a javascript onchange handler for your status field that hides or shows the container fields according to status. Here is a similar example where I have a select list to choose between paypal and cheque, and two text fields "Cheque payable to", and "Paypal address", where the correct field shows up according to what is selected in the select list. So I create a javascript file:
- Code: Select all
jQuery(document).ready(function($){
if (typeof(swete) == 'undefined' ) swete = {};
if ( typeof(swete.tables) == 'undefined') swete.tables = {};
swete.tables.affiliate_accounts = {
updatePaymentFields: function(sel){
if ( jQuery(sel).val() == 'Paypal'){
jQuery('#paypal_address_form_row').css('display','');
jQuery('#cheque_payable_to_form_row').css('display','none');
} else if ( jQuery(sel).val() == 'Cheque' ){
jQuery('#paypal_address_form_row').css('display','none');
jQuery('#cheque_payable_to_form_row').css('display','');
} else {
jQuery('#paypal_address_form_row').css('display','none');
jQuery('#cheque_payable_to_form_row').css('display','none');
}
}
};
swete.tables.affiliate_accounts.updatePaymentFields(
$('#payment_method').get(0)
);
});
This uses Jquery to make things easier. Jquery is distributed in js/jquery.packed.js.
Then I just include this javascript file before the new and edit record forms by implementing the following in the delegate class:
- Code: Select all
function block__before_new_record_form(){
echo "<script type=\"text/javascript\" src=\"".df_absolute_url(DATAFACE_SITE_URL.'/tables/affiliate_accounts/af
}
function block__before_edit_record_form(){
echo "<script type=\"text/javascript\" src=\"".df_absolute_url(DATAFACE_SITE_URL.'/tables/affiliate_accounts/affiliate_accounts.js').'"></script>';
);
}