If a button is needed that is labeled as '<button>' and has an
'onClick' attribute with some javascript containing a text parameter
the code can't be created since when 'escape' is set to false in
options (button default) the script is OK but buttons label will not
be encoded.
Setting 'escape' to true HTML encodes my script, too, which is wrong.

echo $this->Form->button('<button>', array('onClick => 'function(\'xxx
\')'));
results
<button type="submit" onClick="function('xxx')"><button></button>

echo $this->Form->button('<button>', array('onClick' => 'function(\'xxx
\')', 'escape' => true));
results
<button type="submit"
onClick="function(&#039;xxx&#039;)">&lt;button&gt;</button>

echo $this->Form->button('<button>', array('onClick' => 'function(\'xxx
\')', 'escape' => false));
results
<button type="submit" onClick="function('xxx')"><button></button>


A similar problem is to create a select field with an 'onChange'
attribute containing the same javascript as above. By this default of
'escape'
attribute is set true which is of course desirable to have the select
options HTML encoded. But irrespectively of this attribute the script
will
ALWAYS be encoded as shown below so that makes it uninterpretable.

echo $this->Form->select('field', array('1'=>'<one>', '2'=>'<two>'),
null, array('onChange' => 'function(\'yyy\')'));
<select name="data[field]" onChange="function(&#039;yyy&#039;)"
id="field">
<option value=""></option>
<option value="1">&lt;one&gt;</option>
<option value="2">&lt;two&gt;</option>
</select>

echo $this->Form->select('field', array('1'=>'<one>', '2'=>'<two>'),
null, array('onChange' => 'function(\'yyy\')', 'escape' => true));
<select name="data[field]" onChange="function(&#039;yyy&#039;)"
id="field">
<option value=""></option>
<option value="1">&lt;one&gt;</option>
<option value="2">&lt;two&gt;</option>
</select>

echo $this->Form->select('field', array('1'=>'<one>', '2'=>'<two>'),
null, array('onChange' => 'function(\'yyy\')', 'escape' => false));
<select name="data[field]" onChange="function(&#039;yyy&#039;)"
id="field">
<option value=""></option>
<option value="1"><one></option>
<option value="2"><two></option>
</select>

Any idea how to correct it? Should a ticket be created according to
this problem?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to