Description->setEscape(false);
Closed this issue · 3 comments
yellowsatsuma commented
There doesnt appear to be a way of setting within a form
$element->getDecorator('Description')->setEscape(false);
below is the example of my "password" field
$this->addElement('password', 'password', array(
'label' => 'Password',
'prepend' => '<i class="icon-lock"></i>',
'filter' => 'StringTrim',
'description' => array(
array(
'description' => '<a href="forgotpassword">Forgot password?</a>',
'options' => array('escape' => false)
)
),
'AllowEmpty' => false,
'validators' => array(
array(
'validator' => 'StringLength',
'options' => array(
'min' => 8,
'max' => 50,
'messages' => array(
Zend_Validate_StringLength::INVALID => Zend_Registry::get('LOGIN_ERROR'),
Zend_Validate_StringLength::TOO_SHORT => 'Password ' . Zend_Registry::get('ERROR_LENGTH'),
Zend_Validate_StringLength::TOO_LONG => 'Password ' . Zend_Registry::get('ERROR_LENGTH')
)
)
)
)
));
the resulting output is simply "Array" rather than the options being set.
theUniC commented
I'm not sure why you cannot disable description automatic escaping, as this library has nothing to do with the Description decorator (it's being set in some points and that's it). Can you paste an example code of your entire form class?
Regards,
Christian.
yellowsatsuma commented
setName("login");
$this->setMethod('post');
$this->setElementsBelongTo('bootstrap');
$this->addElement('text', 'username', array(
'label' => 'Username',
'prepend' => '',
'filter' => 'StringTrim',
'AllowEmpty' => false,
'validators' => array(array(
'validator' => 'StringLength',
'options' => array(
'min' => 3,
'max' => 50,
'messages' => array(
Zend_Validate_StringLength::INVALID => Zend_Registry::get('LOGIN_ERROR'),
Zend_Validate_StringLength::TOO_SHORT => 'Username ' . Zend_Registry::get('ERROR_LENGTH'),
Zend_Validate_StringLength::TOO_LONG => 'Username ' . Zend_Registry::get('ERROR_LENGTH')
)
))
)
)
);
$this->addElement('password', 'password', array(
'label' => 'Password',
'prepend' => '',
'filter' => 'StringTrim',
'description' => array(
'description' => 'Forgot password?',
'options' => array(
'escape' => false,
)
),
'AllowEmpty' => false,
'validators' => array(array(
'validator' => 'StringLength',
'options' => array(
'min' => 8,
'max' => 50,
'messages' => array(
Zend_Validate_StringLength::INVALID => Zend_Registry::get('LOGIN_ERROR'),
Zend_Validate_StringLength::TOO_SHORT => 'Password ' . Zend_Registry::get('ERROR_LENGTH'),
Zend_Validate_StringLength::TOO_LONG => 'Password ' . Zend_Registry::get('ERROR_LENGTH')
)
))
)
)
);
$this->addElement('button', 'submit', array(
'label' => 'Login',
'buttonType' => Twitter_Bootstrap_Form_Element_Submit::BUTTON_SUCCESS,
'icon' => 'ok',
'whiteIcon' => true,
'iconPosition' => Twitter_Bootstrap_Form_Element_Button::ICON_POSITION_RIGHT,
'type' => 'submit',
));
/*$this->addDisplayGroup(
array('username', 'password','submit'),
'Login',
array('legend' => 'Account Login')
);*/
}
}
the result is "Array"
'description' => 'Forgot password?',
outputs the escaped text but of course thats not of much use
yellowsatsuma commented
turned out i just needed to add this line
$this->password->getDecorator('description')->setEscape(false);