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 8419155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:32:05+00:00 2026-06-10T02:32:05+00:00

I’m fighting with a Zend_dojo_form. Here is (part of) the code: class Application_Form_RegistrationForm extends

  • 0

I’m fighting with a Zend_dojo_form.

Here is (part of) the code:

class Application_Form_RegistrationForm extends Zend_Dojo_Form {

    private $_user;
    private $_admin;
    private $_teamadmin;
    private $_newuser;
    private $_redirect;

    public function __construct($admin = false, $user = null, $redirect = '') {
        //blablabla
        parent::__construct();
    }

    public function init() {

        Zend_Dojo::enableForm($this);

        $this->setMethod('post');
        $this->setAttribs(array(
            'id' => 'formRegistration',
            'name' => 'formRegistration',
        ));

        //some decorators

        if ($this->_admin) {
            $this->addElement(
                //blabla + inline javascript
                'onChange' => "if(this == ".E_UserRole::OPERATOR.") dojo.query(\".perms\").style({ display:\"block\" });  else dojo.query(\".perms\").style({ display:\"none\" }); "
                )
            );
        }

        if (Application_Manager_Login::hasRole(E_UserRole::ADMIN)) {
                //add some display:none elements
                $permission_decorators  = array(
                    "DijitElement",
                    "Errors",
                    array(array("data" => "HtmlTag"), array("tag" => "td", "class" => "perms", "style"=> "display:none", )),
                    array("Label", array("tag" => "td", "class" => "perms", "style"=> "display:none", 'escape' => false, 'requiredSuffix' => ' <span class="red">*</span>')),
                    array(array("row" => "HtmlTag"), array("tag" => "tr"))
                );

                //hidden element
                $this->addElement(
                    'CheckBox',
                    'permission_content',
                    array(
                        'decorators' => $permission_decorators,
                        'label'          => 'Gestione contenuti',
                        'checkedValue'   => true,
                        'uncheckedValue' => false,
                        'checked'        => $this->_user->permission_content,
                    )
                );      
        }
        //submit button and other stuff
    }
}

As you can see I’ve put some inline javascript to show/hide some options when the user_role changes.

Now the situation is a bit complex. I could keep writing inline javascript but I’d like to declare a js function on the beginning and just call it from the onchange Event.

Since this form is called by several controllers I won’t add this function manually each time a

new RegistrationForm();

is called.

  • 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-06-10T02:32:07+00:00Added an answer on June 10, 2026 at 2:32 am

    Ok, I came up with this solution..

    function addJavascript(){
    
            echo "<script>
            function toggle( e ){
                alert(e);
                if(e == ".E_UserRole::USER." || e == ".E_UserRole::ADMIN."){ 
                    dojo.query(\".perms\").style({ display:\"none\" });
                }  
                else { 
                    dojo.query(\".perms\").style({ display:\"block\" }); 
                }
            }   
            </script>
            ";
    
    }
    

    I declared this function inside the class and I just call it in the beginning with:

    $this->addJavascript();
    

    then in the onChange i call the toggle function I need (function that will become more complex, I need this workaround to make it readable) with:

    $this->addElement(
           //blabla
           'onChange' => "toggle(this)",
           )
    );
    

    hope this helps someone else 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

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.