Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like FormValidator often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use FormValidator, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 8 | class FormValidator extends HTML_QuickForm |
||
| 9 | { |
||
| 10 | const LAYOUT_HORIZONTAL = 'horizontal'; |
||
| 11 | const LAYOUT_INLINE = 'inline'; |
||
| 12 | const LAYOUT_BOX = 'box'; |
||
| 13 | const LAYOUT_BOX_NO_LABEL = 'box-no-label'; |
||
| 14 | |||
| 15 | public $with_progress_bar = false; |
||
| 16 | private $layout; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Constructor |
||
| 20 | * @param string $name Name of the form |
||
| 21 | * @param string $method (optional) Method ('post' (default) or 'get') |
||
| 22 | * @param string $action (optional) Action (default is $PHP_SELF) |
||
| 23 | * @param string $target (optional) Form's target defaults to '_self' |
||
| 24 | * @param mixed $attributes (optional) Extra attributes for <form> tag |
||
| 25 | * @param string $layout |
||
| 26 | * @param bool $trackSubmit (optional) Whether to track if the form was |
||
| 27 | * submitted by adding a special hidden field (default = true) |
||
| 28 | */ |
||
| 29 | public function __construct( |
||
| 110 | |||
| 111 | /** |
||
| 112 | * @return string |
||
| 113 | */ |
||
| 114 | public function getFormTemplate() |
||
| 123 | |||
| 124 | /** |
||
| 125 | * @todo this function should be added in the element class |
||
| 126 | * @return string |
||
| 127 | */ |
||
| 128 | public function getDefaultElementTemplate() |
||
| 155 | |||
| 156 | /** |
||
| 157 | * @return string |
||
| 158 | */ |
||
| 159 | public function getLayout() |
||
| 163 | |||
| 164 | /** |
||
| 165 | * @param string $layout |
||
| 166 | */ |
||
| 167 | public function setLayout($layout) |
||
| 171 | |||
| 172 | /** |
||
| 173 | * Adds a text field to the form. |
||
| 174 | * A trim-filter is attached to the field. |
||
| 175 | * @param string $label The label for the form-element |
||
| 176 | * @param string $name The element name |
||
| 177 | * @param bool $required (optional) Is the form-element required (default=true) |
||
| 178 | * @param array $attributes (optional) List of attributes for the form-element |
||
| 179 | * @return HTML_QuickForm_text |
||
| 180 | */ |
||
| 181 | public function addText($name, $label, $required = true, $attributes = array()) |
||
| 191 | |||
| 192 | /** |
||
| 193 | * The "date_range_picker" element creates 2 hidden fields |
||
| 194 | * "elementName" + "_start" and "elementName" + "_end" |
||
| 195 | * For example if the name is "range", you will have 2 new fields |
||
| 196 | * when executing $form->getSubmitValues() |
||
| 197 | * "range_start" and "range_end" |
||
| 198 | * |
||
| 199 | * @param string $name |
||
| 200 | * @param string $label |
||
| 201 | * @param bool $required |
||
| 202 | * @param array $attributes |
||
| 203 | */ |
||
| 204 | View Code Duplication | public function addDateRangePicker($name, $label, $required = true, $attributes = array()) |
|
| 214 | |||
| 215 | /** |
||
| 216 | * @param string $name |
||
| 217 | * @param string $label |
||
| 218 | * @param array $attributes |
||
| 219 | * |
||
| 220 | * @return mixed |
||
| 221 | */ |
||
| 222 | public function addDatePicker($name, $label, $attributes = []) |
||
| 226 | |||
| 227 | /** |
||
| 228 | * @param string $name |
||
| 229 | * @param string $label |
||
| 230 | * @param array $attributes |
||
| 231 | * |
||
| 232 | * @return mixed |
||
| 233 | */ |
||
| 234 | public function addSelectLanguage($name, $label, $options = [], $attributes = []) |
||
| 238 | |||
| 239 | /** |
||
| 240 | * @param string $name |
||
| 241 | * @param string $label |
||
| 242 | * @param array $options |
||
| 243 | * @param array $attributes |
||
| 244 | * @throws |
||
| 245 | */ |
||
| 246 | public function addSelectAjax($name, $label, $options = [], $attributes = []) |
||
| 259 | |||
| 260 | /** |
||
| 261 | * @param string $name |
||
| 262 | * @param string $label |
||
| 263 | * @param array $attributes |
||
| 264 | * |
||
| 265 | * @return mixed |
||
| 266 | */ |
||
| 267 | public function addDateTimePicker($name, $label, $attributes = []) |
||
| 271 | |||
| 272 | /** |
||
| 273 | * @param string $name |
||
| 274 | * @param string $value |
||
| 275 | */ |
||
| 276 | public function addHidden($name, $value) |
||
| 280 | |||
| 281 | /** |
||
| 282 | * @param string $name |
||
| 283 | * @param string $label |
||
| 284 | * @param array $attributes |
||
| 285 | * |
||
| 286 | * @return HTML_QuickForm_textarea |
||
| 287 | */ |
||
| 288 | public function addTextarea($name, $label, $attributes = array()) |
||
| 292 | |||
| 293 | /** |
||
| 294 | * @param string $name |
||
| 295 | * @param string $label |
||
| 296 | * @param string $icon font-awesome |
||
| 297 | * @param string $style default|primary|success|info|warning|danger|link |
||
| 298 | * @param string $size large|default|small|extra-small |
||
| 299 | * @param string $class Example plus is transformed to icon fa fa-plus |
||
| 300 | * @param array $attributes |
||
| 301 | * |
||
| 302 | * @return HTML_QuickForm_button |
||
| 303 | */ |
||
| 304 | public function addButton( |
||
| 338 | |||
| 339 | /** |
||
| 340 | * Returns a button with the primary color and a check mark |
||
| 341 | * @param string $label Text appearing on the button |
||
| 342 | * @param string $name Element name (for form treatment purposes) |
||
| 343 | * @param bool $createElement Whether to use the create or add method |
||
| 344 | * |
||
| 345 | * @return HTML_QuickForm_button |
||
| 346 | */ |
||
| 347 | public function addButtonSave($label, $name = 'submit', $createElement = false) |
||
| 360 | |||
| 361 | /** |
||
| 362 | * Returns a cancel button |
||
| 363 | * @param string $label Text appearing on the button |
||
| 364 | * @param string $name Element name (for form treatment purposes) |
||
| 365 | * @param bool $createElement Whether to use the create or add method |
||
| 366 | * |
||
| 367 | * @return HTML_QuickForm_button |
||
| 368 | */ |
||
| 369 | public function addButtonCancel($label, $name = 'submit', $createElement = false) |
||
| 382 | |||
| 383 | /** |
||
| 384 | * Returns a button with the primary color and a "plus" icon |
||
| 385 | * @param string $label Text appearing on the button |
||
| 386 | * @param string $name Element name (for form treatment purposes) |
||
| 387 | * @param bool $createElement Whether to use the create or add method |
||
| 388 | * @param array $attributes Additional attributes |
||
| 389 | * |
||
| 390 | * @return HTML_QuickForm_button |
||
| 391 | */ |
||
| 392 | public function addButtonCreate($label, $name = 'submit', $createElement = false, $attributes = array()) |
||
| 405 | |||
| 406 | /** |
||
| 407 | * Returns a button with the primary color and a pencil icon |
||
| 408 | * @param string $label Text appearing on the button |
||
| 409 | * @param string $name Element name (for form treatment purposes) |
||
| 410 | * @param bool $createElement Whether to use the create or add method |
||
| 411 | * @return HTML_QuickForm_button |
||
| 412 | */ |
||
| 413 | public function addButtonUpdate($label, $name = 'submit', $createElement = false) |
||
| 426 | |||
| 427 | /** |
||
| 428 | * Returns a button with the danger color and a trash icon |
||
| 429 | * @param string $label Text appearing on the button |
||
| 430 | * @param string $name Element name (for form treatment purposes) |
||
| 431 | * @param bool $createElement Whether to use the create or add method |
||
| 432 | * |
||
| 433 | * @return HTML_QuickForm_button |
||
| 434 | */ |
||
| 435 | public function addButtonDelete($label, $name = 'submit', $createElement = false) |
||
| 448 | |||
| 449 | /** |
||
| 450 | * Returns a move style button |
||
| 451 | * @param string $label Text appearing on the button |
||
| 452 | * @param string $name Element name (for form treatment purposes) |
||
| 453 | * @param bool $createElement Whether to use the create or add method |
||
| 454 | * |
||
| 455 | * @return HTML_QuickForm_button |
||
| 456 | */ |
||
| 457 | public function addButtonMove($label, $name = 'submit', $createElement = false) |
||
| 470 | |||
| 471 | |||
| 472 | /** |
||
| 473 | * Returns a button with the primary color and a paper-plane icon |
||
| 474 | * @param string $label Text appearing on the button |
||
| 475 | * @param string $name Element name (for form treatment purposes) |
||
| 476 | * @param bool $createElement Whether to use the create or add method |
||
| 477 | * |
||
| 478 | * @return HTML_QuickForm_button |
||
| 479 | */ |
||
| 480 | public function addButtonSend($label, $name = 'submit', $createElement = false, $attributes = array()) |
||
| 493 | |||
| 494 | /** |
||
| 495 | * Returns a button with the default (grey?) color and a magnifier icon |
||
| 496 | * @param string $label Text appearing on the button |
||
| 497 | * @param string $name Element name (for form treatment purposes) |
||
| 498 | * |
||
| 499 | * @return HTML_QuickForm_button |
||
| 500 | */ |
||
| 501 | public function addButtonSearch($label = null, $name = 'submit') |
||
| 509 | |||
| 510 | /** |
||
| 511 | * Returns a button with the primary color and a right-pointing arrow icon |
||
| 512 | * @param string $label Text appearing on the button |
||
| 513 | * @param string $name Element name (for form treatment purposes) |
||
| 514 | * @param array $attributes Additional attributes |
||
| 515 | * @return HTML_QuickForm_button |
||
| 516 | */ |
||
| 517 | public function addButtonNext($label, $name = 'submit', $attributes = array()) |
||
| 529 | |||
| 530 | /** |
||
| 531 | * Returns a button with the primary color and a check mark icon |
||
| 532 | * @param string $label Text appearing on the button |
||
| 533 | * @param string $name Element name (for form treatment purposes) |
||
| 534 | * @param bool $createElement Whether to use the create or add method |
||
| 535 | * @return HTML_QuickForm_button |
||
| 536 | */ |
||
| 537 | public function addButtonImport($label, $name = 'submit', $createElement = false) |
||
| 550 | |||
| 551 | /** |
||
| 552 | * Returns a button with the primary color and a check-mark icon |
||
| 553 | * @param string $label Text appearing on the button |
||
| 554 | * @param string $name Element name (for form treatment purposes) |
||
| 555 | * @param bool $createElement Whether to use the create or add method |
||
| 556 | * @return HTML_QuickForm_button |
||
| 557 | */ |
||
| 558 | public function addButtonExport($label, $name = 'submit', $createElement = false) |
||
| 571 | |||
| 572 | /** |
||
| 573 | * Shortcut to filter button |
||
| 574 | * @param string $label Text appearing on the button |
||
| 575 | * @param string $name Element name (for form treatment purposes) |
||
| 576 | * @param bool $createElement Whether to use the create or add method |
||
| 577 | * @return HTML_QuickForm_button |
||
| 578 | */ |
||
| 579 | public function addButtonFilter($label, $name = 'submit', $createElement = false) |
||
| 592 | |||
| 593 | /** |
||
| 594 | * Shortcut to reset button |
||
| 595 | * @param string $label Text appearing on the button |
||
| 596 | * @param string $name Element name (for form treatment purposes) |
||
| 597 | * @param bool $createElement Whether to use the create or add method |
||
| 598 | * @return HTML_QuickForm_button |
||
| 599 | */ |
||
| 600 | public function addButtonReset($label, $name = 'reset', $createElement = false) |
||
| 632 | |||
| 633 | /** |
||
| 634 | * Returns a button with the primary color and an upload icon |
||
| 635 | * @param string $label Text appearing on the button |
||
| 636 | * @param string $name Element name (for form treatment purposes) |
||
| 637 | * @param bool $createElement Whether to use the create or add method |
||
| 638 | * |
||
| 639 | * @return HTML_QuickForm_button |
||
| 640 | */ |
||
| 641 | public function addButtonUpload($label, $name = 'submit', $createElement = false) |
||
| 654 | |||
| 655 | /** |
||
| 656 | * Returns a button with the primary color and a download icon |
||
| 657 | * @param string $label Text appearing on the button |
||
| 658 | * @param string $name Element name (for form treatment purposes) |
||
| 659 | * @param bool $createElement Whether to use the create or add method |
||
| 660 | * |
||
| 661 | * @return HTML_QuickForm_button |
||
| 662 | */ |
||
| 663 | public function addButtonDownload($label, $name = 'submit', $createElement = false) |
||
| 676 | |||
| 677 | /** |
||
| 678 | * Returns a button with the primary color and a magnifier icon |
||
| 679 | * @param string $label Text appearing on the button |
||
| 680 | * @param string $name Element name (for form treatment purposes) |
||
| 681 | * @param bool $createElement Whether to use the create or add method |
||
| 682 | * |
||
| 683 | * @return HTML_QuickForm_button |
||
| 684 | */ |
||
| 685 | View Code Duplication | public function addButtonPreview($label, $name = 'submit', $createElement = false) |
|
| 698 | |||
| 699 | /** |
||
| 700 | * Returns a button with the primary color and a copy (double sheet) icon |
||
| 701 | * @param string $label Text appearing on the button |
||
| 702 | * @param string $name Element name (for form treatment purposes) |
||
| 703 | * @param bool $createElement Whether to use the create or add method |
||
| 704 | * |
||
| 705 | * @return HTML_QuickForm_button |
||
| 706 | */ |
||
| 707 | View Code Duplication | public function addButtonCopy($label, $name = 'submit', $createElement = false) |
|
| 720 | |||
| 721 | /** |
||
| 722 | * @param string $name |
||
| 723 | * @param string $label |
||
| 724 | * @param string $text |
||
| 725 | * @param array $attributes |
||
| 726 | * |
||
| 727 | * @return HTML_QuickForm_checkbox |
||
| 728 | */ |
||
| 729 | public function addCheckBox($name, $label, $text = '', $attributes = array()) |
||
| 733 | |||
| 734 | /** |
||
| 735 | * @param string $name |
||
| 736 | * @param string $label |
||
| 737 | * @param array $options |
||
| 738 | * @param array $attributes |
||
| 739 | * |
||
| 740 | * @return HTML_QuickForm_group |
||
| 741 | */ |
||
| 742 | View Code Duplication | public function addCheckBoxGroup($name, $label, $options = array(), $attributes = array()) |
|
| 758 | |||
| 759 | /** |
||
| 760 | * @param string $name |
||
| 761 | * @param string $label |
||
| 762 | * @param array $options |
||
| 763 | * @param array $attributes |
||
| 764 | * |
||
| 765 | * @return HTML_QuickForm_radio |
||
| 766 | */ |
||
| 767 | View Code Duplication | public function addRadio($name, $label, $options = array(), $attributes = array()) |
|
| 776 | |||
| 777 | /** |
||
| 778 | * @param string $name |
||
| 779 | * @param string $label |
||
| 780 | * @param array $options |
||
| 781 | * @param array $attributes |
||
| 782 | * |
||
| 783 | * @return HTML_QuickForm_select |
||
| 784 | */ |
||
| 785 | public function addSelect($name, $label, $options = array(), $attributes = array()) |
||
| 789 | |||
| 790 | /** |
||
| 791 | * @param $name |
||
| 792 | * @param $label |
||
| 793 | * @param $collection |
||
| 794 | * @param array $attributes |
||
| 795 | * @param bool $addNoneOption |
||
| 796 | * @param string $textCallable set a function getStringValue() by default __toString() |
||
| 797 | * |
||
| 798 | * @return HTML_QuickForm_element |
||
| 799 | */ |
||
| 800 | public function addSelectFromCollection( |
||
| 825 | |||
| 826 | /** |
||
| 827 | * @param string $label |
||
| 828 | * @param string $text |
||
| 829 | * |
||
| 830 | * @return HTML_QuickForm_label |
||
| 831 | */ |
||
| 832 | public function addLabel($label, $text) |
||
| 836 | |||
| 837 | /** |
||
| 838 | * @param string $text |
||
| 839 | */ |
||
| 840 | public function addHeader($text) |
||
| 844 | |||
| 845 | /** |
||
| 846 | * @param string $name |
||
| 847 | * @param string $label |
||
| 848 | * @param array $attributes |
||
| 849 | * @throws Exception if the file doesn't have an id |
||
| 850 | */ |
||
| 851 | public function addFile($name, $label, $attributes = array()) |
||
| 879 | |||
| 880 | /** |
||
| 881 | * @param string $snippet |
||
| 882 | */ |
||
| 883 | public function addHtml($snippet) |
||
| 887 | |||
| 888 | /** |
||
| 889 | * Adds a HTML-editor to the form |
||
| 890 | * @param string $name |
||
| 891 | * @param string $label The label for the form-element |
||
| 892 | * @param bool $required (optional) Is the form-element required (default=true) |
||
| 893 | * @param bool $fullPage (optional) When it is true, the editor loads completed html code for a full page. |
||
| 894 | * @param array $config (optional) Configuration settings for the online editor. |
||
| 895 | * @param bool $style |
||
| 896 | */ |
||
| 897 | public function addHtmlEditor( |
||
| 931 | |||
| 932 | /** |
||
| 933 | * Adds a Google Maps Geolocalization field to the form |
||
| 934 | * |
||
| 935 | * @param $name |
||
| 936 | * @param $label |
||
| 937 | */ |
||
| 938 | public function addGeoLocationMapField($name, $label) |
||
| 1084 | |||
| 1085 | /** |
||
| 1086 | * @param string $name |
||
| 1087 | * @param string $label |
||
| 1088 | * |
||
| 1089 | * @return mixed |
||
| 1090 | */ |
||
| 1091 | public function addButtonAdvancedSettings($name, $label = '') |
||
| 1097 | |||
| 1098 | /** |
||
| 1099 | * Adds a progress loading image to the form. |
||
| 1100 | * |
||
| 1101 | */ |
||
| 1102 | public function addProgress($delay = 2, $label = '') |
||
| 1113 | |||
| 1114 | /** |
||
| 1115 | * This function has been created for avoiding changes directly within QuickForm class. |
||
| 1116 | * When we use it, the element is threated as 'required' to be dealt during validation. |
||
| 1117 | * @param array $elements The array of elements |
||
| 1118 | * @param string $message The message displayed |
||
| 1119 | */ |
||
| 1120 | public function add_multiple_required_rule($elements, $message) |
||
| 1125 | |||
| 1126 | /** |
||
| 1127 | * Displays the form. |
||
| 1128 | * If an element in the form didn't validate, an error message is showed |
||
| 1129 | * asking the user to complete the form. |
||
| 1130 | */ |
||
| 1131 | public function display() |
||
| 1135 | |||
| 1136 | /** |
||
| 1137 | * Returns the HTML code of the form. |
||
| 1138 | * @return string $return_value HTML code of the form |
||
| 1139 | */ |
||
| 1140 | public function returnForm() |
||
| 1170 | |||
| 1171 | /** |
||
| 1172 | * Returns the HTML code of the form. |
||
| 1173 | * If an element in the form didn't validate, an error message is showed |
||
| 1174 | * asking the user to complete the form. |
||
| 1175 | * |
||
| 1176 | * @return string $return_value HTML code of the form |
||
| 1177 | * |
||
| 1178 | * @author Patrick Cool <[email protected]>, Ghent University, august 2006 |
||
| 1179 | * @author Julio Montoya |
||
| 1180 | * @deprecated use returnForm() |
||
| 1181 | */ |
||
| 1182 | public function return_form() |
||
| 1186 | |||
| 1187 | /** |
||
| 1188 | * Create a form validator based on an array of form data: |
||
| 1189 | * |
||
| 1190 | * array( |
||
| 1191 | * 'name' => 'zombie_report_parameters', //optional |
||
| 1192 | * 'method' => 'GET', //optional |
||
| 1193 | * 'items' => array( |
||
| 1194 | * array( |
||
| 1195 | * 'name' => 'ceiling', |
||
| 1196 | * 'label' => 'Ceiling', //optional |
||
| 1197 | * 'type' => 'date', |
||
| 1198 | * 'default' => date() //optional |
||
| 1199 | * ), |
||
| 1200 | * array( |
||
| 1201 | * 'name' => 'active_only', |
||
| 1202 | * 'label' => 'ActiveOnly', |
||
| 1203 | * 'type' => 'checkbox', |
||
| 1204 | * 'default' => true |
||
| 1205 | * ), |
||
| 1206 | * array( |
||
| 1207 | * 'name' => 'submit_button', |
||
| 1208 | * 'type' => 'style_submit_button', |
||
| 1209 | * 'value' => get_lang('Search'), |
||
| 1210 | * 'attributes' => array('class' => 'search') |
||
| 1211 | * ) |
||
| 1212 | * ) |
||
| 1213 | * ); |
||
| 1214 | * |
||
| 1215 | * @param array $form_data |
||
| 1216 | * @deprecated use normal FormValidator construct |
||
| 1217 | * |
||
| 1218 | * @return FormValidator |
||
| 1219 | */ |
||
| 1220 | public static function create($form_data) |
||
| 1271 | |||
| 1272 | /** |
||
| 1273 | * @return HTML_QuickForm_Renderer_Default |
||
| 1274 | */ |
||
| 1275 | public static function getDefaultRenderer() |
||
| 1281 | |||
| 1282 | /** |
||
| 1283 | * Adds a input of type url to the form. |
||
| 1284 | * @param string $name The label for the form-element |
||
| 1285 | * @param string $label The element name |
||
| 1286 | * @param bool $required Optional. Is the form-element required (default=true) |
||
| 1287 | * @param array $attributes Optional. List of attributes for the form-element |
||
| 1288 | */ |
||
| 1289 | View Code Duplication | public function addUrl($name, $label, $required = true, $attributes = array()) |
|
| 1299 | |||
| 1300 | /** |
||
| 1301 | * Adds a text field for letters to the form. |
||
| 1302 | * A trim-filter is attached to the field. |
||
| 1303 | * @param string $name The element name |
||
| 1304 | * @param string $label The label for the form-element |
||
| 1305 | * @param bool $required Optional. Is the form-element required (default=true) |
||
| 1306 | * @param array $attributes Optional. List of attributes for the form-element |
||
| 1307 | */ |
||
| 1308 | View Code Duplication | public function addTextLettersOnly( |
|
| 1345 | |||
| 1346 | /** |
||
| 1347 | * Adds a text field for alphanumeric characters to the form. |
||
| 1348 | * A trim-filter is attached to the field. |
||
| 1349 | * @param string $name The element name |
||
| 1350 | * @param string $label The label for the form-element |
||
| 1351 | * @param bool $required Optional. Is the form-element required (default=true) |
||
| 1352 | * @param array $attributes Optional. List of attributes for the form-element |
||
| 1353 | */ |
||
| 1354 | View Code Duplication | public function addTextAlphanumeric( |
|
| 1391 | |||
| 1392 | /** |
||
| 1393 | * @param string $name |
||
| 1394 | * @param $label |
||
| 1395 | * @param bool $required |
||
| 1396 | * @param array $attributes |
||
| 1397 | * @param bool $allowNegative |
||
| 1398 | * @param integer $minValue |
||
| 1399 | * @param null $maxValue |
||
| 1400 | */ |
||
| 1401 | public function addFloat( |
||
| 1470 | |||
| 1471 | /** |
||
| 1472 | * Adds a text field for letters and spaces to the form. |
||
| 1473 | * A trim-filter is attached to the field. |
||
| 1474 | * @param string $name The element name |
||
| 1475 | * @param string $label The label for the form-element |
||
| 1476 | * @param bool $required Optional. Is the form-element required (default=true) |
||
| 1477 | * @param array $attributes Optional. List of attributes for the form-element |
||
| 1478 | */ |
||
| 1479 | View Code Duplication | public function addTextLettersAndSpaces( |
|
| 1516 | |||
| 1517 | /** |
||
| 1518 | * Adds a text field for alphanumeric and spaces characters to the form. |
||
| 1519 | * A trim-filter is attached to the field. |
||
| 1520 | * @param string $name The element name |
||
| 1521 | * @param string $label The label for the form-element |
||
| 1522 | * @param bool $required Optional. Is the form-element required (default=true) |
||
| 1523 | * @param array $attributes Optional. List of attributes for the form-element |
||
| 1524 | */ |
||
| 1525 | View Code Duplication | public function addTextAlphanumericAndSpaces( |
|
| 1562 | |||
| 1563 | /** |
||
| 1564 | * @param string $url |
||
| 1565 | */ |
||
| 1566 | public function addMultipleUpload($url) |
||
| 1594 | |||
| 1595 | /** |
||
| 1596 | * |
||
| 1597 | * @param string $url page that will handle the upload |
||
| 1598 | * @param string $inputName |
||
| 1599 | */ |
||
| 1600 | private function addMultipleUploadJavascript($url, $inputName) |
||
| 1713 | |||
| 1714 | /** |
||
| 1715 | * @param string $elementName |
||
| 1716 | * @param string $groupName if element is inside a group |
||
| 1717 | * @throws Exception |
||
| 1718 | */ |
||
| 1719 | public function addPasswordRule($elementName, $groupName = '') |
||
| 1754 | |||
| 1755 | /** |
||
| 1756 | * Add an element with user ID and avatar to the form. |
||
| 1757 | * It needs a Chamilo\UserBundle\Entity\User as value. The exported value is the Chamilo\UserBundle\Entity\User ID |
||
| 1758 | * @see \UserAvatar |
||
| 1759 | * @param string $name |
||
| 1760 | * @param string $label |
||
| 1761 | * @param string $imageSize Optional. Small, medium or large image |
||
| 1762 | * @param string $subtitle Optional. The subtitle for the field |
||
| 1763 | * @return \InputAvatar |
||
| 1764 | */ |
||
| 1765 | public function addUserAvatar($name, $label, $imageSize = 'small', $subtitle = '') |
||
| 1769 | } |
||
| 1770 | |||
| 1816 |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()method in theSoncalls the wrong method in the parent class.