@@ -170,7 +170,7 @@ protected function _wrapTemplates ($templates, $callback, $params) {
170170 $ result = call_user_func_array ($ callback , $ params ) ;
171171 $ this ->templates ($ oldTemplates ) ;
172172 return $ result ;
173- }
173+ }
174174
175175 /**
176176 *
@@ -184,7 +184,7 @@ protected function _wrapTemplates ($templates, $callback, $params) {
184184 protected function _matchButton ($ html ) {
185185 return strpos ($ html , '<button ' ) !== FALSE || strpos ($ html , 'type="submit" ' ) !== FALSE ;
186186 }
187-
187+
188188 protected function _getDefaultTemplateVars (&$ options ) {
189189 $ options += [
190190 'templateVars ' => []
@@ -213,38 +213,38 @@ protected function _getDefaultTemplateVars (&$options) {
213213 }
214214 return $ options ;
215215 }
216-
216+
217217 public function formatTemplate ($ name , $ data ) {
218218 return $ this ->templater ()->format ($ name , $ this ->_getDefaultTemplateVars ($ data ));
219219 }
220-
220+
221221 public function widget ($ name , array $ data = []) {
222222 return parent ::widget ($ name , $ this ->_getDefaultTemplateVars ($ data ));
223223 }
224-
224+
225225 protected function _inputContainerTemplate ($ options ) {
226226 return parent ::_inputContainerTemplate (array_merge ($ options , [
227227 'options ' => $ this ->_getDefaultTemplateVars ($ options ['options ' ])
228228 ]));
229229 }
230-
230+
231231 /**
232- *
233- * Create a Twitter Bootstrap like form.
234- *
232+ *
233+ * Create a Twitter Bootstrap like form.
234+ *
235235 * New options available:
236- * - horizontal: boolean, specify if the form is horizontal
237- * - inline: boolean, specify if the form is inline
238- * - search: boolean, specify if the form is a search form
239- *
236+ * - horizontal: boolean, specify if the form is horizontal
237+ * - inline: boolean, specify if the form is inline
238+ * - search: boolean, specify if the form is a search form
239+ *
240240 * Unusable options:
241- * - inputDefaults
242- *
241+ * - inputDefaults
242+ *
243243 * @param $model The model corresponding to the form
244244 * @param $options Options to customize the form
245- *
245+ *
246246 * @return The HTML tags corresponding to the openning of the form
247- *
247+ *
248248 **/
249249 public function create ($ model = null , Array $ options = array ()) {
250250 if (isset ($ options ['cols ' ])) {
@@ -258,14 +258,14 @@ public function create($model = null, Array $options = array()) {
258258 unset($ options ['horizontal ' ]);
259259 $ this ->inline = $ this ->_extractOption ('inline ' , $ options , false ) ;
260260 unset($ options ['inline ' ]) ;
261- if ($ this ->horizontal ) {
262- $ options = $ this ->addClass ($ options , 'form-horizontal ' ) ;
263- }
261+ if ($ this ->horizontal ) {
262+ $ options = $ this ->addClass ($ options , 'form-horizontal ' ) ;
263+ }
264264 else if ($ this ->inline ) {
265265 $ options = $ this ->addClass ($ options , 'form-inline ' ) ;
266266 }
267267 $ options ['role ' ] = 'form ' ;
268- return parent ::create ($ model , $ options ) ;
268+ return parent ::create ($ model , $ options ) ;
269269 }
270270
271271 /**
@@ -288,7 +288,7 @@ protected function _getColClass ($what, $offset = false) {
288288 }
289289 return implode (' ' , $ classes ) ;
290290 }
291-
291+
292292 protected function _wrapInputGroup ($ addonOrButtons ) {
293293 if ($ addonOrButtons ) {
294294 if (is_string ($ addonOrButtons )) {
@@ -586,31 +586,31 @@ protected function _createButtonOptions (array $options = array()) {
586586 }
587587 return $ options ;
588588 }
589-
589+
590590 /**
591- *
591+ *
592592 * Create & return a Twitter Like button.
593- *
593+ *
594594 * ### New options:
595595 *
596596 * - bootstrap-type: Twitter bootstrap button type (primary, danger, info, etc.)
597597 * - bootstrap-size: Twitter bootstrap button size (mini, small, large)
598- *
598+ *
599599 */
600600 public function button ($ title , array $ options = []) {
601601 return $ this ->_easyIcon ('parent::button ' , $ title , $ this ->_createButtonOptions ($ options ));
602602 }
603-
603+
604604 /**
605- *
605+ *
606606 * Create & return a Twitter Like button group.
607- *
607+ *
608608 * @param $buttons The buttons in the group
609609 * @param $options Options for div method
610610 *
611611 * Extra options:
612612 * - vertical true/false
613- *
613+ *
614614 **/
615615 public function buttonGroup ($ buttons , array $ options = array ()) {
616616 $ vertical = $ this ->_extractOption ('vertical ' , $ options , false ) ;
@@ -621,85 +621,85 @@ public function buttonGroup ($buttons, array $options = array()) {
621621 }
622622 return $ this ->Html ->tag ('div ' , implode ('' , $ buttons ), $ options ) ;
623623 }
624-
624+
625625 /**
626- *
626+ *
627627 * Create & return a Twitter Like button toolbar.
628- *
628+ *
629629 * @param $buttons The groups in the toolbar
630630 * @param $options Options for div method
631- *
631+ *
632632 **/
633633 public function buttonToolbar (array $ buttonGroups , array $ options = array ()) {
634634 $ options = $ this ->addClass ($ options , 'btn-toolbar ' ) ;
635635 return $ this ->Html ->tag ('div ' , implode ('' , $ buttonGroups ), $ options ) ;
636636 }
637-
637+
638638 /**
639- *
639+ *
640640 * Create & return a twitter bootstrap dropdown button. This function is a shortcut for:
641- *
641+ *
642642 * $this->Form->$buttonGroup([
643- * $this->Form->button($title, $options),
643+ * $this->Form->button($title, $options),
644644 * $this->Html->dropdown($menu, [])
645645 * ]);
646- *
646+ *
647647 * @param $title The text in the button
648648 * @param $menu HTML tags corresponding to menu options (which will be wrapped
649- * into <li> tag). To add separator, pass 'divider'.
649+ * into <li> tag). To add separator, pass 'divider'.
650650 * @param $options Options for button
651- *
651+ *
652652 */
653653 public function dropdownButton ($ title , array $ menu = [], array $ options = []) {
654-
654+
655655 $ options ['type ' ] = false ;
656656 $ options ['data-toggle ' ] = 'dropdown ' ;
657657 $ options = $ this ->addClass ($ options , "dropdown-toggle " ) ;
658-
658+
659659 return $ this ->buttonGroup ([
660660 $ this ->button ($ title .' <span class="caret"></span> ' , $ options ),
661661 $ this ->bHtml ->dropdown ($ menu )
662662 ]);
663663
664664 }
665-
665+
666666 /**
667- *
667+ *
668668 * Create & return a Twitter Like submit input.
669- *
669+ *
670670 * New options:
671- * - bootstrap-type: Twitter bootstrap button type (primary, danger, info, etc.)
672- * - bootstrap-size: Twitter bootstrap button size (mini, small, large)
673- *
671+ * - bootstrap-type: Twitter bootstrap button type (primary, danger, info, etc.)
672+ * - bootstrap-size: Twitter bootstrap button size (mini, small, large)
673+ *
674674 * Unusable options: div
675- *
676- **/
675+ *
676+ **/
677677 public function submit ($ caption = null , array $ options = array ()) {
678678 return parent ::submit ($ caption , $ this ->_createButtonOptions ($ options )) ;
679679 }
680-
680+
681681 /** SPECIAL FORM **/
682-
682+
683683 /**
684- *
684+ *
685685 * Create a basic bootstrap search form.
686- *
686+ *
687687 * @param $model The model of the form
688688 * @param $options The options that will be pass to the BootstrapForm::create method
689689 * @param $inpOpts The options that will be pass to the BootstrapForm::input method
690690 * @param $btnOpts The options that will be pass to the BootstrapForm::button method
691- *
691+ *
692692 * Extra options:
693693 * - id ID of the input (and fieldname)
694694 * - label The input label (default false)
695695 * - placeholder The input placeholder (default "Search... ")
696696 * - button The search button text (default: "Search")
697697 * - _input Options for the input (overrided by $inpOpts)
698698 * - _button Options for the button (overrided by $btnOpts)
699- *
699+ *
700700 **/
701701 public function searchForm ($ model = null , $ options = [], $ inpOpts = [], $ btnOpts = []) {
702-
702+
703703 $ options += [
704704 'id ' => 'search ' ,
705705 'label ' => false ,
@@ -708,47 +708,38 @@ public function searchForm ($model = null, $options = [], $inpOpts = [], $btnOpt
708708 '_input ' => [],
709709 '_button ' => []
710710 ];
711-
711+
712712 $ options = $ this ->addClass ($ options , 'form-search ' );
713-
713+
714714 $ btnOpts += $ options ['_button ' ];
715715 unset($ options ['_button ' ]);
716-
716+
717717 $ inpOpts += $ options ['_input ' ];
718718 unset($ options ['_input ' ]);
719-
719+
720720 $ inpOpts += [
721721 'id ' => $ options ['id ' ],
722722 'placeholder ' => $ options ['placeholder ' ],
723723 'label ' => $ options ['label ' ]
724724 ];
725-
725+
726726 unset($ options ['id ' ]) ;
727727 unset($ options ['label ' ]) ;
728728 unset($ options ['placeholder ' ]) ;
729-
729+
730730 $ btnName = $ options ['button ' ];
731731 unset($ options ['button ' ]) ;
732-
732+
733733 $ inpOpts ['append ' ] = $ this ->button ($ btnName , $ btnOpts );
734-
734+
735735 $ options ['inline ' ] = (bool )$ inpOpts ['label ' ];
736-
736+
737737 $ output = '' ;
738-
738+
739739 $ output .= $ this ->create ($ model , $ options ) ;
740740 $ output .= $ this ->input ($ inpOpts ['id ' ], $ inpOpts );
741741 $ output .= $ this ->end () ;
742742
743- /* array(
744- 'label' => $label,
745- 'placeholder' => $placeholder,
746- 'append' => array(
747- $this->button($button, ['style' => 'vertical-align: middle'])
748- )
749- )) ;
750- $output .= $this->end() ; */
751-
752743 return $ output ;
753744 }
754745
0 commit comments