Share

Roadsend PHP SiteManager

The forum address has changed, you have been automatically redirected. Please update any bookmarks to use the new URL.

Subscribe

Filter

You are viewing a single message from this topic. View all messages.

  1. 2004-12-20 09:26:29 UTC
    While this is technically true ("all filters run regardless of the 'required' setting"), I am finding it to be not quite the complete story.

    I have a form in which I would would like to make one field "conditionally" required. That is, field X is required only if the content of field Y is set some way.

    The specific example is a list of members whose member_type field is either full_member or mailing_list_only. For a full_member, we require a name, but not for a mailing_list_only member.

    My first attempt at this was to simply set required=false for the name field and then add a function filter to the name field that implements my conditional checks.

    But I found that the filter would not run on the empty field. Further investigation showed that SM_formEntity::applyFilters specifically prevents a filter from running on a non-required field whose data is empty. While this probably makes sense in general, it completely whacks my approach.

    So I guess the general question is: how would you implement this kind of "conditionally required" behavior?

    I suppose that rather than adding the filter to the
    name field, I could add it to the member_type field. But that seems like a bit of a hack. After all, I want to direct the user to address the missing data in the name field, not the correct content in the member_type field.

    Any ideas would be greatly appreciated.

    Thanks and regards,

    David
< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.