Welcome to the Cookbook

loading...
Please login to continue

7.3.2 Closing the Form

Er is geen nog vertaling vertaling voor deze rubriek. Help ons en vertaal dit.. Meer informatie over vertalingen

The FormHelper also includes an end() method that completes the form markup. Often, end() only outputs a closing form tag, but using end() also allows the FormHelper to insert needed hidden form elements other methods may be depending on.

<?php echo $form->create(); ?>
 
<!-- Form elements go here -->
 
<?php echo $form->end(); ?>
  1. <?php echo $form->create(); ?>
  2. <!-- Form elements go here -->
  3. <?php echo $form->end(); ?>

If a string is supplied as the first parameter to end(), the FormHelper outputs a submit button named accordingly along with the closing form tag.

<?php echo $form->end('Finish'); ?>
 
  1. <?php echo $form->end('Finish'); ?>

Will output:

 
<div class="submit">
    <input type="submit" value="Finish" />
</div>
</form>

You can specify detail settings by passing an array to end().

<?php 
$options = array(
    'name' => 'Update',
    'label' => 'Update!',
    'div' => array(
        'class' => 'glass-pill',
    )
);
echo $form->end($options);
  1. <?php
  2. $options = array(
  3. 'name' => 'Update',
  4. 'label' => 'Update!',
  5. 'div' => array(
  6. 'class' => 'glass-pill',
  7. )
  8. );
  9. echo $form->end($options);

Will output:

<div class="glass-pill"><input type="submit" value="Update!" name="Update"></div>

See the API for further details.