Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3998528
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:32:12+00:00 2026-05-20T07:32:12+00:00

is there a way i can use the Alnum filter for a Zend_Form_Element_Text form

  • 0

is there a way i can use the Alnum filter for a Zend_Form_Element_Text form element but still retain commas ? The input will be command seperated tags for an item.
Do i have to define my own filter ? Is there a way to achieve this using the ‘Callback’ filter type ?

Expected input is tag1,tag2,tag3

$tags=new Zend_Form_Element_Text('tags');
$tags->setLabel('Tags:');
$tags->addFilters(array('Alnum','StripTags','StringTrim','HtmlEntities'));

Update 1:

the Zend_Filter_Alnum has an option to allow whitespace which can be activated by

$tags->addFilters(array('StripTags','StringTrim','HtmlEntities',new Zend_Filter_Alnum(true)));

So the expected input will be tag1 tag2 tag3 but still if anybody could suggest me a way to make it accept tag1,tag2,tag3, it would be awesome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T07:32:12+00:00Added an answer on May 20, 2026 at 7:32 am

    This is just an example , it shouldn’t be used as is in a production environment :

    class My_Filter_AlnumComma implements Zend_Filter_Interface
    {
        public $allowComma;
    
        public function __construct($allowComma = false)
        {
            // have a look at a proper filter construct 
            // and change me
            $this->allowComma = (boolean) $allowComma;
        }
    
        public function getAllowComma()
        {
            return $this->allowComma;
        }
    
        public function setAllowComma($allowComma)
        {
            $this->allowComma = (boolean) $allowComma;
            return $this;
        }
    
        public function filter($value)
        {
            $comma = $this->allowComma ? ',' : '';
            $pattern = '/[^a-zA-Z0-9' . $comma . ']/';        
    
            return preg_replace($pattern, '', (string) $value);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there some way I can use URLs like: http://www.blog.com/team-spirit/ instead of http://www.blog.com/?p=122 in
In the iPhone is there a way I can use JavaScript to close the
Is there a way or tool for Vista I can use to search for
Is there a way to use yield blocks to implement an IEnumerator<T> which can
Is there a way I can use the session created by ASP.NET to authenticate
is there way thats i can preselect an item when the page loads or
Is there a way I can control columns from code. I had a drop
Is there a way I can access (for printout) a list of sub +
Is there a way you can run your UnitTest project against a compiled DLL
Is there some way I can define String[int] to avoid using String.CharAt(int) ?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.