Page tree
Skip to end of metadata
Go to start of metadata

 

Please note that this is only available in FreePBX 13 and higher.

The FreePBX Action Bar was added in version 13, to allow for consistency throughout FreePBX. To get started adding or modifying your form submission buttons you can follow the steps below:

  1. Add a getActionBar method to you module class

    public function getActionBar($request) {
    		$buttons = array();
    		switch($request['display']) {
    			case 'announcement':
    				$buttons = array(
    					'delete' => array(
    						'name' => 'delete',
    						'id' => 'delete',
    						'value' => _('Delete'),
    						'hidden' => ''
    					),
    					'reset' => array(
    						'name' => 'reset',
    						'id' => 'reset',
    						'value' => _('Reset'),
    						'hidden' => ''
    					),
    					'submit' => array(
    						'name' => 'submit',
    						'id' => 'submit',
    						'value' => _('Submit'),
    						'hidden' => ''
    					)
    				);
    				//Don't use empty here as 0 will return true which may not always be desired
    				if (!isset($request['extdisplay']) || trim($request['extdisplay']) == '') {
    					unset($buttons['delete']);
    				}
    			break;
    		}
    		return $buttons;
    	}
  2. Add a class to your form

    <form class="fpbx-submit" name="editAnnouncement" action="" method="post" onsubmit="return checkAnnouncement(editAnnouncement);">
  3. If you form has a Delete button, add an attribute to your form called "data-fpbx-delete"

    <form class="fpbx-submit" name="editAnnouncement" action="" method="post" onsubmit="return checkAnnouncement(editAnnouncement);" data-fpbx-delete="config.php?display=announcement&amp;extdisplay=<?php echo $extdisplay ?>&amp;action=delete">
  4. Remove any buttons that show on your page as this is all handled via FreePBX now.

  5. Note that the module will submit the page as using the action specified, whereas delete uses the data-fpbx-delete attribute.

 

  • No labels