Skip to content

Commit

Permalink
[BF] Require an infrastructure when adding / editing a VLAN - closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
barryo committed Aug 24, 2014
1 parent bd2cf37 commit 78735c5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
12 changes: 6 additions & 6 deletions library/IXP/Form/Infrastructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ public function init()
->addFilter( 'StringToLower' )
->addFilter( 'StringTrim' );
$this->addElement( $shortname );

$isPrimary = $this->createElement( 'checkbox', 'isPrimary' );
$isPrimary->setLabel( 'This is the <em>primary</em> infrastructure' )
->setValue( '0' )
->addValidator( 'InArray', false, [ [ 0, 1 ] ] )
->addFilter( 'Int' );
$this->addElement( $isPrimary );

$this->addElement( IXP_Form_IXP::createAggregateGraphNameElement() );

$this->addElement( self::createSubmitElement( 'submit', _( 'Add' ) ) );
Expand Down Expand Up @@ -107,17 +107,17 @@ public static function getPopulatedSelect( $name = 'ifrastructureid' )
->from( '\\Entities\\Infrastructure', 'e' )
->join( 'e.IXP', 'ix' )
->add( 'orderBy', "ixp ASC, name ASC" );

$maxId = self::populateSelectFromDatabaseQuery( $qb->getQuery(), $sw, '\\Entities\\Infrastructure', 'id', [ 'ixp', 'name' ], 'ixp', 'ASC' );

$sw->setRegisterInArrayValidator( true )
->setRequired( false )
->setAttrib( 'data-maxId', $maxId )
->setLabel( _( 'infrastructure' ) )
->setAttrib( 'class', 'chzn-select-deselect' )
//->addValidator( 'between', false, array( 1, $maxId ) )
->setErrorMessages( [ 'Please select an infrastructure' ] );

return $sw;
}
}

16 changes: 9 additions & 7 deletions library/IXP/Form/Vlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public function init()
$this->addElement( $number );

$infrastructure = IXP_Form_Infrastructure::getPopulatedSelect( 'infrastructure' )
->setRequired( true )
->setRequired( true );

$infrastructure->addValidator( 'between', false, array( 1, $infrastructure->getAttrib( 'data-maxId' ) ) )
->setAttrib( 'class', 'chzn-select' );
$this->addElement( $infrastructure );

Expand All @@ -71,7 +73,7 @@ public function init()
$private->setLabel( 'Private VLAN between a subset of members' )
->setCheckedValue( '1' );
$this->addElement( $private );

$notes = $this->createElement( 'textarea', 'notes' );
$notes->setLabel( 'Notes' )
->setRequired( false )
Expand All @@ -80,7 +82,7 @@ public function init()
->setAttrib( 'class', 'span3' )
->setAttrib( 'rows', 5 );
$this->addElement( $notes );

$this->addElement( self::createSubmitElement( 'submit', _( 'Add' ) ) );
$this->addElement( $this->createCancelElement() );
}
Expand All @@ -104,17 +106,17 @@ public static function getPopulatedSelect( $name = 'vlanid', $publicOnly = false

if( $publicOnly )
$qb->where( "v.private = 0" );

$maxId = self::populateSelectFromDatabaseQuery( $qb->getQuery(), $vlan, '\\Entities\\Vlan', 'id', 'name', 'name', 'ASC' );

$vlan->setRegisterInArrayValidator( true )
->setRequired( true )
->setLabel( _( 'VLAN' ) )
->setAttrib( 'class', 'span3 chzn-select' )
->addValidator( 'between', false, array( 1, $maxId ) )
->setErrorMessages( array( _( 'Please select a VLAN' ) ) );

return $vlan;
}

}

0 comments on commit 78735c5

Please sign in to comment.