Does changing your quote pattern help?

echo $this->Form->select('field', array( '1' => '<one>' , '2' =>
'<two>' ),
                                          null, array('onChange' =>
'function(\"yyy\")'));

\" (because php isn't escaping it) will get sent to the output, which
_should_ render

onclick="function(\"yyy\")" -

I would do some more tests with sending double quotes vs single quotes
for the ent_quote option of the $form helper..



On Aug 5, 5:27 pm, drbuzasi <drbuz...@gmail.com> wrote:
> 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