<?php use_helper('Javascript'?>

<?php include_stylesheets_for_form($form?>
<?php include_javascripts_for_form
($form?>

<form action="<?php echo url_for('band/'.($form->getObject()->isNew() ? 'create' 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<?php if (!$form->getObject()->isNew()): ?>
<input type="hidden" name="sf_method" value="put" />
<?php endif; ?>
  <table id="band">
    <tfoot>
      <tr>
        <td colspan="2">
          <noscript><p>
            <strong>NOTE:</strong> To add more members, please save this form, and more spaces will be presented.
          </p></noscript>

          &nbsp;<a href="<?php echo url_for('band/index'?>">Cancel</a>
          <?php if (!$form->getObject()->isNew()): ?>
            &nbsp;<?php echo link_to('Delete''band/delete?id='.$form->getObject()->getId(), array('method' => 'delete''confirm' => 'Are you sure?')) ?>
          <?php endif; ?>
          <input type="submit" value="Save" />
        </td>
      </tr>
    </tfoot>
    <tbody>
      <?php echo $form ?>
    </tbody>
  </table>
</form>

<?php echo javascript_tag() ?>
  $$('#band table').each(function(e)
  {
    if (e.select('table').length)
    {
      e.select('tbody')[0].id = 'band_members';

      e.insert('<?php echo escape_javascript("
        <tfoot><tr><td colspan=\"2\">"
.
          
button_to_remote('Add member', array(
            
'url' => 'band/memberForm',
            
'with' => "'count='+$$('#band_members table').length",
            
'update' => 'band_members',
            
'position' => 'bottom',
          ))
        .
"</td></tr></tfoot>
      "
?>');
    }
  });
<?php end_javascript_tag() ?>