Using form helper? Is there a way to modify the DOM? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11) +--- Thread: Using form helper? Is there a way to modify the DOM? (/showthread.php?tid=77589) |
Using form helper? Is there a way to modify the DOM? - richb201 - 09-21-2020 I have a form that I created. It is called http://localhost/index.php/FormUserBackend. Near the top I want to append some radio buttons. So I tried this: form_open('views/User_Activity_Survey.php'); $str=form_checkbox( "test1", "Question1",FALSE, "class=form-checkbox id=input_4_3 name=q4_whichOf[]" ); echo ($str); $str=form_checkbox( "test2", "Question2",FALSE, "class=form-checkbox id=input_4_3 name=q4_whichOf[]" ); echo ($str); $str=form_checkbox( "test3", "Question3",FALSE, "class=form-checkbox id=input_4_3 name=q4_whichOf[]" ); echo ($str); form_fieldset_close(); $this->load->view('User_Activity_Survey.php'); Bur when I look at the output in the browser, none of these appended fields display. So I decided to look in the output window and I do see them near the top: X-Powered-By: PHP/7.2.32 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate Pragma: no-cache Set-Cookie: cisession=hbmpjleolom8fuaqdnri0ch1abf0b5cf; expires=Tue, 22-Sep-2020 01:42:18 GMT; Max-Age=28800; path=/; HttpOnly Content-type: text/html; charset=UTF-8 <input type="checkbox" name="test1" value="Question1" class=form-checkbox id=input_4_3 name=q4_whichOf[] /> <input type="checkbox" name="test2" value="Question2" class=form-checkbox id=input_4_3 name=q4_whichOf[] /> <input type="checkbox" name="test3" value="Question3" class=form-checkbox id=input_4_3 name=q4_whichOf[] /> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en-US" class="supernova"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="alternate" type="application/json+oembed" href="https://www.jotform.com/oembed/?format=json&url=https%3A%2F%2Fform.jotform.com%2F202597294899073" title="oEmbed Form"> <link rel="alternate" type="text/xml+oembed" href="https://www.jotform.com/oembed/?format=xml&a etc. They are in the wrong place. Is there some built in tools in CI to manipulate the DOM? This might be better than blindly prepending some checkboxes. RE: Using form helper? Is there a way to modify the DOM? - Natanchikk - 09-21-2020 Hello, as an option for positioning, try creating a header view with the appropriate content. Connect it first, and then your form. RE: Using form helper? Is there a way to modify the DOM? - richb201 - 09-21-2020 So I figure that I needed to modify the DOM. I found this package which will let me modify the DOM from PHP: PHP Simple HTML DOM Parser. The question is when do I do this? I can load the entire view file into a string, modify it, and then "Dump the internal DOM tree back into a string. If the $filename is set, result string will save to file". I am concerned because this is multi user system. I could surely keep the $string in a session, but how do then get load_view() to display it? RE: Using form helper? Is there a way to modify the DOM? - vitnibel - 09-21-2020 Hi, the output of the form in the view at a specific place can be done like this: PHP Code: $form = form_open('views/User_Activity_Survey.php'); and in the place you need of User_Activity_Survey.php: PHP Code: <?php echo $form; ?> RE: Using form helper? Is there a way to modify the DOM? - ojmichael - 09-22-2020 The DOM doesn't really exist server-side, until the page is rendered in the browser it's really just a string of text. You need to render your form at the correct point of the markup, either using a variable as indicated above or by creating a view for the form and using the form helper functions directly there. RE: Using form helper? Is there a way to modify the DOM? - richb201 - 09-24-2020 Thanks OJ. I managed to get it going using koolreport's input library. RE: Using form helper? Is there a way to modify the DOM? - InsiteFX - 09-24-2020 The HTML DOM (Document Object Model) |