gizomo Posted May 7, 2019 Share Posted May 7, 2019 I need to set an attribute for form with single quotes inside the value. Now I have this code: private function getForm($options) { $form = $this->modules->get('InputfieldForm'); $form->action = isset($options['action']) ? $options['action'] : './'; $form->method = 'post'; $form->attr([ 'id+name' => 'contact-form', 'onsubmit' => "ym(53558719, 'reachGoal', 'form_question'); return true;" ]); ... } But on the frontend there is an output: <form id="contact-form" class="form js-simplecontactform InputfieldForm" name="contact-form" method="post" action="./#question" onsubmit="ym(53558719, 'reachGoal', 'form_question'); return true;" data-colspacing="1"> Backslashes before single quotes don't help. The quotes turn into ' What should I do? Link to comment Share on other sites More sharing options...
wbmnfktr Posted May 7, 2019 Share Posted May 7, 2019 Have you tried something like this? 'onsubmit' => "ym(53558719, \'reachGoal\', \'form_question\'); return true;" Link to comment Share on other sites More sharing options...
BitPoet Posted May 7, 2019 Share Posted May 7, 2019 12 minutes ago, gizomo said: What I should do? Nothing. Escaping single quotes as HTML entities is perfectly valid and just an optical thing, the behavior stays the same as if there were literal single quotes. 1 Link to comment Share on other sites More sharing options...
gizomo Posted May 7, 2019 Author Share Posted May 7, 2019 3 hours ago, BitPoet said: Nothing. Escaping single quotes as HTML entities is perfectly valid and just an optical thing, the behavior stays the same as if there were literal single quotes. Thanks. I thought its unavailable. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now