Skip to content

Commit

Permalink
[IM] Enlarge fields - especially chosen dropdowns
Browse files Browse the repository at this point in the history
An update of Bootstrap sometime ago changed how the spans worked introducing this issue.

Closes #133
  • Loading branch information
barryo committed Aug 24, 2014
1 parent d202c38 commit 209a7b7
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 49 deletions.
63 changes: 31 additions & 32 deletions library/IXP/Form/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ class IXP_Form_Customer extends IXP_Form
public function init()
{
$this->setDecorators( [ [ 'ViewScript', [ 'viewScript' => 'customer/forms/edit.phtml' ] ] ] );

$name = $this->createElement( 'text', 'name' );
$name->addValidator( 'stringLength', false, array( 1, 255 ) )
->setRequired( true )
->setLabel( 'Name' )
->setAttrib( 'class', 'span6' )
->setAttrib( 'class', 'span10' )
->addFilter( 'StringTrim' )
->addFilter( new OSS_Filter_StripSlashes() );
$this->addElement( $name );
Expand All @@ -51,7 +51,7 @@ public function init()
->setRegisterInArrayValidator( true )
->setLabel( 'Type' )
->setRequired( true )
->setAttrib( 'class', 'chzn-select span4' )
->setAttrib( 'class', 'chzn-select span8' )
->setErrorMessages( array( 'Please select a customer type' ) );
$this->addElement( $type );

Expand All @@ -60,7 +60,7 @@ public function init()
->addValidator( 'alnum' )
->addValidator( 'regex', false, array('/^[a-z0-9]+/' ) )
->setRequired( true )
->setAttrib( 'class', 'span4' )
->setAttrib( 'class', 'span8' )
->setLabel( 'Short Name' )
->addFilter( 'StringToLower' )
->addFilter( 'StringTrim' );
Expand All @@ -70,7 +70,7 @@ public function init()
$corpwww->addValidator( 'stringLength', false, array( 0, 255 ) )
->setRequired( false )
->setAttrib( 'placeholder', 'http://www.example.com/' )
->setAttrib( 'class', 'span6' )
->setAttrib( 'class', 'span10' )
->setLabel( 'Corporate Website' )
->addFilter( 'StringTrim' )
->addFilter( new OSS_Filter_StripSlashes() );
Expand Down Expand Up @@ -102,21 +102,21 @@ public function init()
->setRegisterInArrayValidator( true )
->setLabel( 'Status' )
->setRequired( true )
->setAttrib( 'class', 'chzn-select span3' )
->setAttrib( 'class', 'chzn-select span8' )
->setErrorMessages( array( 'Please set the customer\'s status' ) );
$this->addElement( $status );

$MD5Support = $this->createElement( 'select', 'MD5Support' );
$MD5Support->setMultiOptions( \Entities\Customer::$MD5_SUPPORT )
->setRegisterInArrayValidator( true )
->setLabel( 'MD5 Support' )
->setRequired( false )
->setAttrib( 'class', 'chzn-select span6' );
->setAttrib( 'class', 'chzn-select span8' );
$this->addElement( $MD5Support );

$abbreviatedName = $this->createElement( 'text', 'abbreviatedName' );
$abbreviatedName->setRequired( false )
->setAttrib( 'class', 'span6' )
->setAttrib( 'class', 'span10' )
->setLabel( 'Abbreviated Name' )
->addFilter( 'StringTrim' )
->addFilter( new OSS_Filter_StripSlashes() );
Expand All @@ -127,23 +127,23 @@ public function init()
$autsys->addValidator('int')
->addValidator( 'greaterThan', false, array( -1 ) )
->setRequired( false )
->setAttrib( 'class', 'span4' )
->setAttrib( 'class', 'span6' )
->setLabel( 'AS Number' );
$this->addElement( $autsys );

$maxprefixes = $this->createElement( 'text', 'maxprefixes' );
$maxprefixes->addValidator('int')
->addValidator( 'greaterThan', false, array( -1 ) )
->setRequired( false )
->setAttrib( 'class', 'span2' )
->setAttrib( 'class', 'span6' )
->setLabel( 'Max Prefixes' );
$this->addElement( $maxprefixes );

$peeringemail = $this->createElement( 'text', 'peeringemail' );
$peeringemail->addValidator('emailAddress' )
->addValidator( 'stringLength', false, array( 0, 64 ) )
->setRequired( false )
->setAttrib( 'class', 'span6' )
->setAttrib( 'class', 'span8' )
->setAttrib( 'placeholder', '[email protected]' )
->setLabel( 'Email' );
$this->addElement( $peeringemail );
Expand All @@ -153,17 +153,17 @@ public function init()
->setRegisterInArrayValidator( true )
->setLabel( 'Peering Policy' )
->setRequired( false )
->setAttrib( 'class', 'chzn-select span3' );
->setAttrib( 'class', 'chzn-select span8' );

$this->addElement( $peeringpolicy );


$peeringmacro = $this->createElement( 'text', 'peeringmacro' );
$peeringmacro->addValidator( 'stringLength', false, array( 0, 255 ) )
->setRequired( false )
->setLabel( 'Peering Macro' )
->addFilter( 'StringTrim' )
->setAttrib( 'class', 'span4' )
->setAttrib( 'class', 'span8' )
->addFilter( new OSS_Filter_StripSlashes() );
$this->addElement( $peeringmacro );

Expand All @@ -183,13 +183,13 @@ public function init()
'peeringDisplayGroup'
);
$this->getDisplayGroup( 'peeringDisplayGroup' )->setLegend( 'Peering Details' );

$nocphone = $this->createElement( 'text', 'nocphone' );
$nocphone->addValidator( 'stringLength', false, array( 0, 255 ) )
->setRequired( false )
->setLabel( 'Phone' )
->setAttrib( 'placeholder', '+353 1 123 4567' )
->setAttrib( 'class', 'span4' )
->setAttrib( 'class', 'span8' )
->addFilter( 'StringTrim' )
->addFilter( new OSS_Filter_StripSlashes() );
$this->addElement( $nocphone );
Expand All @@ -198,7 +198,7 @@ public function init()
$noc24hphone->addValidator( 'stringLength', false, array( 0, 255 ) )
->setRequired( false )
->setAttrib( 'placeholder', '+353 86 876 5432' )
->setAttrib( 'class', 'span4' )
->setAttrib( 'class', 'span8' )
->setLabel( '24h Phone' )
->addFilter( 'StringTrim' )
->addFilter( new OSS_Filter_StripSlashes() );
Expand All @@ -209,7 +209,7 @@ public function init()
->setRequired( false )
->setLabel( 'Fax' )
->setAttrib( 'placeholder', '+353 1 765 4321' )
->setAttrib( 'class', 'span4' )
->setAttrib( 'class', 'span8' )
->addFilter( 'StringTrim' )
->addFilter( new OSS_Filter_StripSlashes() );
$this->addElement( $nocfax );
Expand All @@ -218,7 +218,7 @@ public function init()
$nocemail->addValidator('emailAddress' )
->addValidator( 'stringLength', false, array( 0, 40 ) )
->setRequired( false )
->setAttrib( 'class', 'span6' )
->setAttrib( 'class', 'span8' )
->setAttrib( 'placeholder', '[email protected]' )
->setLabel( 'E-Mail' );
$this->addElement( $nocemail );
Expand All @@ -228,16 +228,16 @@ public function init()
->setRegisterInArrayValidator( true )
->setLabel( 'Hours' )
->setRequired( false )
->setAttrib( 'class', 'chzn-select span2' );
->setAttrib( 'class', 'chzn-select span8' );
$this->addElement( $nochours );


$nocwww = $this->createElement( 'text', 'nocwww' );
$nocwww->addValidator( 'stringLength', false, array( 0, 255 ) )
->setRequired( false )
->setLabel( 'Website' )
->setAttrib( 'placeholder', 'http://www.noc.example.com/' )
->setAttrib( 'class', 'span6' )
->setAttrib( 'class', 'span10' )
->addFilter( 'StringTrim' )
->addFilter( new OSS_Filter_StripSlashes() );
$this->addElement( $nocwww );
Expand All @@ -253,7 +253,7 @@ public function init()
}



/**
* Create a SELECT / dropdown element of all customer names indexed by their id.
*
Expand All @@ -263,16 +263,16 @@ public function init()
public static function getPopulatedSelect( $name = 'custid' )
{
$cust = new Zend_Form_Element_Select( $name );

$maxId = self::populateSelectFromDatabase( $cust, '\\Entities\\Customer', 'id', 'name', 'name', 'ASC' );

$cust->setRegisterInArrayValidator( true )
->setRequired( true )
->setLabel( _( 'Customer' ) )
->setAttrib( 'class', 'span2 chzn-select' )
->addValidator( 'between', false, array( 1, $maxId ) )
->setErrorMessages( array( _( 'Please select a customer' ) ) );

return $cust;
}

Expand Down Expand Up @@ -335,4 +335,3 @@ public function setMultiIXP( $multiIXP, $isEdit )
}

}

22 changes: 11 additions & 11 deletions library/IXP/Form/Interface/Physical.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function init()
$switch = IXP_Form_Switch::getPopulatedSelect( 'switchid' )
->setAttrib( 'class', 'chzn-select span8' );
$this->addElement( $switch );

$switchPorts = $this->createElement( 'select', 'switchportid' );
$switchPorts->setRequired( true )
->setRegisterInArrayValidator( false )
Expand All @@ -50,14 +50,14 @@ public function init()
->addValidator( 'greaterThan', false, array( 'min' => 1 ) )
->setErrorMessages( array( 'Please select a switch port' ) );
$this->addElement( $switchPorts );

$virtualInterface = $this->createElement( 'hidden', 'virtualinterfaceid' );
$this->addElement( $virtualInterface );

$status = $this->createElement( 'select', 'status' );
$status->setMultiOptions( \Entities\PhysicalInterface::$STATES )
->setRegisterInArrayValidator( true )
->setAttrib( 'class', 'chzn-select span4' )
->setAttrib( 'class', 'chzn-select span8' )
->setLabel( 'Status' )
->setErrorMessages( array( 'Please set the status' ) );
$this->addElement( $status );
Expand All @@ -66,7 +66,7 @@ public function init()
$speed = $this->createElement( 'select', 'speed' );
$speed->setMultiOptions( \Entities\PhysicalInterface::$SPEED )
->setRegisterInArrayValidator( true )
->setAttrib( 'class', 'chzn-select span3' )
->setAttrib( 'class', 'chzn-select span8' )
->setLabel( 'Speed' )
->setErrorMessages( array( 'Please set the speed' ) );
$this->addElement( $speed );
Expand All @@ -75,7 +75,7 @@ public function init()
$duplex = $this->createElement( 'select', 'duplex' );
$duplex->setMultiOptions( \Entities\PhysicalInterface::$DUPLEX )
->setRegisterInArrayValidator( true )
->setAttrib( 'class', 'chzn-select span3' )
->setAttrib( 'class', 'chzn-select span8' )
->setLabel( 'Duplex' )
->setErrorMessages( array( 'Please set the duplex' ) );
$this->addElement( $duplex );
Expand All @@ -84,7 +84,7 @@ public function init()
$monitorindex = $this->createElement( 'text', 'monitorindex' );
$monitorindex->addValidator( 'int' )
->setLabel( 'Monitor Index' )
->setAttrib( 'class', 'span3' )
->setAttrib( 'class', 'span8' )
->addFilter( 'StringTrim' )
->addFilter( new OSS_Filter_StripSlashes() );
$this->addElement( $monitorindex );
Expand All @@ -97,13 +97,13 @@ public function init()
->setAttrib( 'cols', 60 )
->setAttrib( 'rows', 5 );
$this->addElement( $notes );

$this->addElement( self::createSubmitElement( 'submit', _( 'Add' ) ) );
$this->addElement( $this->createCancelElement() );

$preselectSwitchPort = $this->createElement( 'hidden', 'preselectSwitchPort' );
$this->addElement( $preselectSwitchPort );

$preselectPhysicalInterface = $this->createElement( 'hidden', 'preselectPhysicalInterface' );
$this->addElement( $preselectPhysicalInterface );
}
Expand All @@ -123,7 +123,7 @@ public function enableFanoutPort( $modeEnabled )
$fanout->setLabel( 'Associate a fanout port' )
->setCheckedValue( '1' );
$this->addElement( $fanout );

$switcher = IXP_Form_Switch::getPopulatedSelect( 'fn_switchid' );
$switcher->setRequired( false )
->setAttrib( 'class', 'chzn-select' )
Expand Down Expand Up @@ -151,7 +151,7 @@ public function enableFanoutPort( $modeEnabled )

$preselectSwitchPort = $this->createElement( 'hidden', 'fn_preselectSwitchPort' );
$this->addElement( $preselectSwitchPort );

$preselectPhysicalInterface = $this->createElement( 'hidden', 'fn_preselectPhysicalInterface' );
$this->addElement( $preselectPhysicalInterface );

Expand Down
11 changes: 5 additions & 6 deletions library/IXP/Form/Interface/Virtual.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ class IXP_Form_Interface_Virtual extends IXP_Form
public function init()
{
$this->setDecorators( [ [ 'ViewScript', [ 'viewScript' => 'virtual-interface/forms/virtual-interface.phtml' ] ] ] );

$this->addElement( IXP_Form_Customer::getPopulatedSelect( 'custid' ) );
$this->getElement( 'custid' )->setAttrib( 'class', 'chzn-select span4' );
$this->getElement( 'custid' )->setAttrib( 'class', 'chzn-select span8' );

$name = $this->createElement( 'text', 'name' );
$name->addValidator( 'stringLength', false, array( 0, 255 ) )
->setRequired( false )
Expand Down Expand Up @@ -84,13 +84,12 @@ public function init()
[ 'custid', 'name', 'description', 'channelgroup', 'mtu', 'trunk' ],
'virtualInterfaceDisplayGroup'
);

$this->getDisplayGroup( 'virtualInterfaceDisplayGroup' )->setLegend( 'Customer Connection Details' );


$this->addElement( self::createSubmitElement( 'submit', _( 'Add' ) ) );
$this->addElement( $this->createCancelElement() );
}

}

0 comments on commit 209a7b7

Please sign in to comment.