Jump to content

Wrapping form around $table


Martijn Geerts
 Share

Recommended Posts

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.

  • Like 1
Link to comment
Share on other sites

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

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());
  • Like 2
Link to comment
Share on other sites

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...