Forums

Embedding multi page form in article

petermazzi 04 Jan, 2011
Hi there, I would like to embed a multi page form in an article of Joomla.

I am using so far the following code: {chronocontact}name of the form{/chronocontact}

It is working ok with normal forms, but if I put the name of the mother form it does not appear.

Is it something wrong ?
GreyHead 04 Jan, 2011
Hi petermazzi,

Yes and no - I just don't think that the plug-in supports multi-page forms.

You might be able to get a similar result using a single form with Joomla! tabs but this may also be pushing it a bit.

Bob
petermazzi 04 Jan, 2011
Ok, thanks... but, sorry, what do you mean with Joomla tabs ? Could you please explain a bit more in detail ?

Thanks
GreyHead 04 Jan, 2011
Hi petermazzi,

Joomla! includes some code to enable tabbed layouts - see the Admin forms for example. You can use this to create a tabbed layout in the Front-end as well.

There's an example here - this is a ChronoForm even thuough it it's only displaying data.

There's also the Joomla! Tabs & Slides Extenhsion but I'm not sure how well that works with ChronoForms. And if you search here I think there was a thread on using a Roktab layout last month.

Bob
petermazzi 04 Jan, 2011
The example is sort of what I was looking for, the only drawback is that doing single forms for each tab, I will receive the results by different emails (as many as the number of tabs....)
GreyHead 04 Jan, 2011
Hi pteremazzi,

It's actually a single form with many tabs.

Bob
petermazzi 05 Jan, 2011
It would be interesting to know how to do such a form !!!

Ie, how to connect the different tabs (each tab is supposed to be an article) in one single form ?
GreyHead 05 Jan, 2011
Hi petermazzi,

Not separate articles. It's a single ChronoForm broken into many tabs using the Joomla! Tab code. Here's a simplified version the main section of the Form HTML:
// start output
$q = "";
if ( !$pane ) {
  $q = " : ".$categories[$cat_id]->name;
}
echo "<h3 class='flow_main_heading'>Question Detail$q</h3>";
//no results, notify user
if ( !count($data) ) {
  $mainframe->enqueuemessage('No records were found', 'error');
//results found, proceed
} else {
  // initialise tabs
  if ( $pane ) {
    jimport('joomla.html.pane');
    $pane =& JPane::getInstance('tabs'); 
    echo $pane->startPane( 'pane' );
  } 
  $i = 0;
  $category = 0;
  foreach ( $data as $d) {
    if ( $d->cat_id != $category ) {
      // mark this category as 'in use'
      $categories[$d->cat_id]->used = true;
      if ( $category && $pane) {
        // close the previous tab
        echo "</tbody></table>";
        echo $pane->endPanel();
      }
      $category = $d->cat_id;
      $i = 0;
      // open a new tab
      if ( $pane ) {
        echo $pane->startPanel( $categories[$d->cat_id]->name, $d->cat_id );
      }
      echo "<table style='width:100%;'>
        <thead>
          <tr>
            <th style='text-align:left; width:200px;'>Question</th>
            <th style='width:60px;' >Frequency</th>
            <th style='width:60px;' >Amount</th>
            <th colspan='12'>Monthly data</th>
          </tr>
        </thead>
        <tbody>
        ";
    }
    $m_data = explode('|', $d->m_data);
    $m_data = "<td'>".implode("</td><td>", $m_data)."</td>";
    echo "<tr style='".$style[$i++ % 2]."'>
      <td>".$d->description."</td>
      <td>$freq</td>
      <td style='text-align:right;'>$amount</td>
      $m_data
      </tr>";
  }
  echo "</tbody></table>";
  if ( $pane ) {
    echo $pane->endPanel();
    echo $pane->endPane( 'pane' );
  }
}
I've take a lot of the logic code out but you should now be able to see the use of the $pane object.

Bob
petermazzi 12 Jan, 2011
I copied and pasted on a test form your code, but it does not seem to work...

Do I have to do anything else ?

Hi petermazzi,

Not separate articles. It's a single ChronoForm broken into many tabs using the Joomla! Tab code. Here's a simplified version the main section of the Form HTML:

// start output
$q = "";
if ( !$pane ) {
  $q = " : ".$categories[$cat_id]->name;
}
echo "<h3 class='flow_main_heading'>Question Detail$q</h3>";
//no results, notify user
if ( !count($data) ) {
  $mainframe->enqueuemessage('No records were found', 'error');
//results found, proceed
} else {
  // initialise tabs
  if ( $pane ) {
    jimport('joomla.html.pane');
    $pane =& JPane::getInstance('tabs'); 
    echo $pane->startPane( 'pane' );
  } 
  $i = 0;
  $category = 0;
  foreach ( $data as $d) {
    if ( $d->cat_id != $category ) {
      // mark this category as 'in use'
      $categories[$d->cat_id]->used = true;
      if ( $category && $pane) {
        // close the previous tab
        echo "</tbody></table>";
        echo $pane->endPanel();
      }
      $category = $d->cat_id;
      $i = 0;
      // open a new tab
      if ( $pane ) {
        echo $pane->startPanel( $categories[$d->cat_id]->name, $d->cat_id );
      }
      echo "<table style='width:100%;'>
        <thead>
          <tr>
            <th style='text-align:left; width:200px;'>Question</th>
            <th style='width:60px;' >Frequency</th>
            <th style='width:60px;' >Amount</th>
            <th colspan='12'>Monthly data</th>
          </tr>
        </thead>
        <tbody>
        ";
    }
    $m_data = explode('|', $d->m_data);
    $m_data = "<td'>".implode("</td><td>", $m_data)."</td>";
    echo "<tr style='".$style[$i++ % 2]."'>
      <td>".$d->description."</td>
      <td>$freq</td>
      <td style='text-align:right;'>$amount</td>
      $m_data
      </tr>";
  }
  echo "</tbody></table>";
  if ( $pane ) {
    echo $pane->endPanel();
    echo $pane->endPane( 'pane' );
  }
}
I've take a lot of the logic code out but you should now be able to see the use of the $pane object.

Bob

GreyHead 12 Jan, 2011
Hi petermazzi,

Well, no it won't work. I cut a lot of code out of it and depends on some database tables. It's just an example of using the Joomla! Pane/Panels code.

Bob
This topic is locked and no more replies can be posted.