Martijn Geerts Posted September 25, 2012 Share Posted September 25, 2012 I'm using: $table = $this->modules->get("MarkupAdminDataTable"); Then when I need to have a form wrapped around it I'll end up like this $output = "<form action='./dosomething' method='post'>"; $output .= $table->render(); $output .= "</form>"; Is there a cleaner way to do it ? Link to comment Share on other sites More sharing options...
nik Posted September 25, 2012 Share Posted September 25, 2012 One way would be to use a separate file for the view. I tried not to use any html in my .module-file and instead ended up with a TemplateFile instance. The view is created during init() and different variables are populated depending on the given input. Then view's render() method is called to output it all. Hmm, the explanation isn't very clear, but if this was what you were trying to achieve then you might want to take a look at my Selector Test module's implementation at https://github.com/n...essSelectorTest. The lines with "$this->view" in the module-file and the view itself (view.php) should give an idea of what I was trying to say above. If you're building a module, even a process one, then this could be helpful. If this came up somewhere else, you'll probably get much better suggestions later on from others. 1 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted September 25, 2012 Author Share Posted September 25, 2012 Thank you Nik, trying to build a youtube video scraper (based on gData Api) process module. Wich import video id's to pages. Yesterday installed your module at home, didn't looked at the source. Will install it here & gonna check it out. I think i get what you're saying... Thank you Nik for your explanation. Link to comment Share on other sites More sharing options...
Soma Posted September 25, 2012 Share Posted September 25, 2012 What about using InputfieldForm. ... $form = $this->modules->get("InputfieldForm"); $form->attr('action', $url); $form->attr('method', 'post'); $form->attr('id', 'myform'); ... $form->attr('value', $table->render()); 2 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted September 25, 2012 Author Share Posted September 25, 2012 (edited) I'm confused about your "InputfieldForm" solution. The table contains (depending on search) 50 or less rows with checkboxes. @Nik: thank you, I can use your render solution in many other situations to. Edited September 25, 2012 by Martijn Geerts Link to comment Share on other sites More sharing options...
Soma Posted September 25, 2012 Share Posted September 25, 2012 What so confusing about a form? Link to comment Share on other sites More sharing options...
Martijn Geerts Posted September 25, 2012 Author Share Posted September 25, 2012 Think you're setting the attribute 'value' from the form tag, with the contents of the variable $table. want PW spit out something like this & love nice code without markup. It's not a big problem to do it any other way. <form action="./import"> <table class="AdminDataTable AdminDataList AdminDataTableSortable"> <thead> <tr> <th class="header"> <label><input type="checkbox" id="check_all" value="check_all" checked="checked"> </label></th> <th class="header"></th> <th class="header">YouTube ID</th> <th class="header">YouTube User</th> <th class="header">Title</th> <th class="header">Description</th> </tr> </thead> <tbody> <!-- repeated & repeated --> <tr> <td> <label><input type="checkbox" id="InputfieldCheckbox11" value="mAnUFR5lsiY" checked="checked"> </label></td> <td><div style="position: relative; overflow: hidden;"> <a href="http://i.ytimg.com/vi/mAnUFR5lsiY/0.jpg" class="lightbox"> <img src="http://i.ytimg.com/vi/mAnUFR5lsiY/1.jpg" width="60" height="45" style="margin: -8px 0;"> </a> </div></td> <td><a href="https://www.youtube.com/embed/mAnUFR5lsiY?autoplay=1&fs=1&modestbranding=0&color=white&rel=0&theme=light&autohide=2&enablejsapi=1&showinfo=0&origin=processvideodata" class="iframe video" title="*THROWBACK* Westwood - Ndubz freestyle with Westwood on Radio 1"><span class="icon">►</span> mAnUFR5lsiY</a></td> <td><a href="https://www.youtube.com/profile?user=timwestwoodtv">timwestwoodtv</a></td> <td>*THROWBACK* Westwood - Nd…</td> <td>Westwood in the studio with UK hip hop group NDubz…</td> </tr> <tr> <td> <label><input type="checkbox" id="InputfieldCheckbox60" value="MRiybrVTS90" checked="checked"> </label></td> <td><div style="position: relative; overflow: hidden;"> <a href="http://i.ytimg.com/vi/MRiybrVTS90/0.jpg" class="lightbox"> <img src="http://i.ytimg.com/vi/MRiybrVTS90/1.jpg" width="60" height="45" style="margin: -8px 0;"> </a> </div></td> <td><a href="https://www.youtube.com/embed/MRiybrVTS90?autoplay=1&fs=1&modestbranding=0&color=white&rel=0&theme=light&autohide=2&enablejsapi=1&showinfo=0&origin=processvideodata" class="iframe video" title="Taylor Swift - Begin Again (Single) (full) (LYRICS)"><span class="icon">►</span> MRiybrVTS90</a></td> <td><a href="https://www.youtube.com/profile?user=horcruxkilling">horcruxkilling</a></td> <td>Taylor Swift - Begin Agai…</td> <td>Taylor Swift's second single off of her new album …</td> </tr> </tbody> </table> <p><a href="import/"><button class="ui-button ui-widget ui-state-default ui-corner-all" name="button" value="Import Selected" type="button"><span class="ui-button-text">Import Selected</span></button></a> </p></form> Link to comment Share on other sites More sharing options...
Soma Posted September 25, 2012 Share Posted September 25, 2012 Yeah it's exactly what it does (your code). have your tried it? InputfieldForm is just a wrapper. Link to comment Share on other sites More sharing options...
Martijn Geerts Posted September 25, 2012 Author Share Posted September 25, 2012 Yeah did tried it many times, but it didn't function somehow. Now tried again, and it does... Thank you for your time. (did something stupid I think) Link to comment Share on other sites More sharing options...
ryan Posted September 25, 2012 Share Posted September 25, 2012 Think you're setting the attribute 'value' from the form tag, with the contents of the variable $table. Soma's example is the way the InputfieldForm is meant to be used in this instance. Forms in HTML don't have a 'value' attribute, so we repurposed it in InputfieldForm to function as a way to put in whatever you want. However, if you wanted to do it the more traditional Inputfield way (using InputfieldMarkup), you could also do this, though it's not necessary: ... $form = $this->modules->get("InputfieldForm"); $form->attr('action', $url); $form->attr('method', 'post'); $form->attr('id', 'myform'); $field = $this->modules->get("InputfieldMarkup"); $field->value = $table->render(); $form->add($field); ... Link to comment Share on other sites More sharing options...
Martijn Geerts Posted September 25, 2012 Author Share Posted September 25, 2012 Love to see the possibilities. I've used Soma's approach for now. Learned a lot today, thanks guys. Tomorrow (boss sends me away now), gonna try to figure out why I can't get the changed value of InputfieldPageListSelect via jQuery. Don't know why I always get the old value. $('#id_of_the_InputfieldPageListSelect').change(function(){ alert('I alert the old value here:' + this.value + 'but want to get the changed value'); }); 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