Skip to content

Commit

Permalink
[BF] save loopback name and IP as null rather than empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
barryo committed Oct 11, 2017
1 parent a6bcdca commit 7a86c1c
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions application/controllers/SwitchController.php
Expand Up @@ -347,7 +347,7 @@ private function _resolve( $hn, $type )
* @param bool $isEdit True of we are editing an object, false otherwise
* @param array $options Options passed onto Zend_Form
* @param string $cancelLocation Where to redirect to if 'Cancal' is clicked
* @return void
* @return bool
*/
protected function formPostProcess( $form, $object, $isEdit, $options = null, $cancelLocation = null )
{
Expand All @@ -371,7 +371,7 @@ protected function formPostProcess( $form, $object, $isEdit, $options = null, $c
* @param IXP_Form_Switch $form The form object
* @param \Entities\Switcher $object The Doctrine2 entity (being edited or blank for add)
* @param bool $isEdit True of we are editing an object, false otherwise
* @return void
* @return bool
*/
protected function addPostValidate( $form, $object, $isEdit )
{
Expand Down Expand Up @@ -415,6 +415,39 @@ protected function addPostValidate( $form, $object, $isEdit )
return true;
}

/**
* Pre db flush hook that can be overridden by subclasses for add and edit.
*
* This is called if the user POSTs a valid form after the posted
* data has been assigned to the object and just before it is (persisted
* if adding) and the database is flushed.
*
* This hook can prevent flushing by returning false.
*
* **NB: You should not `flush()` here unless you know what you are doing**
*
* A call to `flush()` is made after this method returns true ensuring a
* transactional `flush()` for all.
*
* @param OSS_Form $form The Send form object
* @param object $object The Doctrine2 entity (being edited or blank for add)
* @param bool $isEdit True if we are editing, otherwise false
* @return bool If false, the form is not persisted
*/
protected function addPreFlush( $form, $object, $isEdit )
{
if( $form->getElement( 'loopback_ip' )->getValue() == "" ) {
$object->setLoopbackIp( null );
}

if( $form->getElement( 'loopback_name' )->getValue() == "" ) {
$object->setLoopbackName( null );
}

return true;
}


/**
* Clear the cache after a change to a switch
*
Expand Down

0 comments on commit 7a86c1c

Please sign in to comment.