@@ -105,7 +105,6 @@ class BootstrapFormHelper extends FormHelper {
105105
106106 public $ horizontal = false ;
107107 public $ inline = false ;
108- public $ search = false ;
109108 public $ colSize ;
110109
111110 /**
@@ -257,8 +256,6 @@ public function create($model = null, Array $options = array()) {
257256 }
258257 $ this ->horizontal = $ this ->_extractOption ('horizontal ' , $ options , false );
259258 unset($ options ['horizontal ' ]);
260- $ this ->search = $ this ->_extractOption ('search ' , $ options , false ) ;
261- unset($ options ['search ' ]) ;
262259 $ this ->inline = $ this ->_extractOption ('inline ' , $ options , false ) ;
263260 unset($ options ['inline ' ]) ;
264261 if ($ this ->horizontal ) {
@@ -267,9 +264,6 @@ public function create($model = null, Array $options = array()) {
267264 else if ($ this ->inline ) {
268265 $ options = $ this ->addClass ($ options , 'form-inline ' ) ;
269266 }
270- if ($ this ->search ) {
271- $ options = $ this ->addClass ($ options , 'form-search ' ) ;
272- }
273267 $ options ['role ' ] = 'form ' ;
274268 return parent ::create ($ model , $ options ) ;
275269 }
@@ -686,33 +680,68 @@ public function submit($caption = null, array $options = array()) {
686680 *
687681 * @param $model The model of the form
688682 * @param $options The options that will be pass to the BootstrapForm::create method
683+ * @param $inpOpts The options that will be pass to the BootstrapForm::input method
684+ * @param $btnOpts The options that will be pass to the BootstrapForm::button method
689685 *
690686 * Extra options:
691- * - label: The input label (default false)
692- * - placeholder: The input placeholder (default "Search... ")
693- * - button: The search button text (default: "Search")
687+ * - id ID of the input (and fieldname)
688+ * - label The input label (default false)
689+ * - placeholder The input placeholder (default "Search... ")
690+ * - button The search button text (default: "Search")
691+ * - _input Options for the input (overrided by $inpOpts)
692+ * - _button Options for the button (overrided by $btnOpts)
694693 *
695694 **/
696- public function searchForm ($ model = null , $ options = array ()) {
695+ public function searchForm ($ model = null , $ options = [], $ inpOpts = [], $ btnOpts = []) {
696+
697+ $ options += [
698+ 'id ' => 'search ' ,
699+ 'label ' => false ,
700+ 'placeholder ' => 'Search... ' ,
701+ 'button ' => 'Search ' ,
702+ '_input ' => [],
703+ '_button ' => []
704+ ];
705+
706+ $ options = $ this ->addClass ($ options , 'form-search ' );
707+
708+ $ btnOpts += $ options ['_button ' ];
709+ unset($ options ['_button ' ]);
710+
711+ $ inpOpts += $ options ['_input ' ];
712+ unset($ options ['_input ' ]);
697713
698- $ label = $ this ->_extractOption ('label ' , $ options , false ) ;
714+ $ inpOpts += [
715+ 'id ' => $ options ['id ' ],
716+ 'placeholder ' => $ options ['placeholder ' ],
717+ 'label ' => $ options ['label ' ]
718+ ];
719+
720+ unset($ options ['id ' ]) ;
699721 unset($ options ['label ' ]) ;
700- $ placeholder = $ this ->_extractOption ('placeholder ' , $ options , 'Search... ' ) ;
701722 unset($ options ['placeholder ' ]) ;
702- $ button = $ this ->_extractOption ('button ' , $ options , 'Search ' ) ;
723+
724+ $ btnName = $ options ['button ' ];
703725 unset($ options ['button ' ]) ;
704726
727+ $ inpOpts ['append ' ] = $ this ->button ($ btnName , $ btnOpts );
728+
729+ $ options ['inline ' ] = (bool )$ inpOpts ['label ' ];
730+
705731 $ output = '' ;
706732
707- $ output .= $ this ->create ($ model , array_merge (array ('search ' => true , 'inline ' => (bool )$ label ), $ options )) ;
708- $ output .= $ this ->input ('search ' , array (
733+ $ output .= $ this ->create ($ model , $ options ) ;
734+ $ output .= $ this ->input ($ inpOpts ['id ' ], $ inpOpts );
735+ $ output .= $ this ->end () ;
736+
737+ /* array(
709738 'label' => $label,
710739 'placeholder' => $placeholder,
711740 'append' => array(
712- $ this ->button ($ button , array ( 'style ' => 'vertical-align: middle ' ) )
741+ $this->button($button, [ 'style' => 'vertical-align: middle'] )
713742 )
714743 )) ;
715- $ output .= $ this ->end () ;
744+ $output .= $this->end() ; */
716745
717746 return $ output ;
718747 }
0 commit comments