| @@ 1252-1289 (lines=38) @@ | ||
| 1249 | * @param bool $required Optional. Is the form-element required (default=true) |
|
| 1250 | * @param array $attributes Optional. List of attributes for the form-element |
|
| 1251 | */ |
|
| 1252 | public function addTextAlphanumericAndSpaces( |
|
| 1253 | $name, |
|
| 1254 | $label, |
|
| 1255 | $required = false, |
|
| 1256 | $attributes = [] |
|
| 1257 | ) { |
|
| 1258 | $attributes = array_merge( |
|
| 1259 | $attributes, |
|
| 1260 | [ |
|
| 1261 | 'pattern' => '[a-zA-Z0-9ñÑ\s]+', |
|
| 1262 | 'title' => get_lang('OnlyLettersAndNumbersAndSpaces') |
|
| 1263 | ] |
|
| 1264 | ); |
|
| 1265 | ||
| 1266 | $this->addElement( |
|
| 1267 | 'text', |
|
| 1268 | $name, |
|
| 1269 | [ |
|
| 1270 | $label, |
|
| 1271 | get_lang('OnlyLettersAndNumbersAndSpaces') |
|
| 1272 | ], |
|
| 1273 | $attributes |
|
| 1274 | ); |
|
| 1275 | ||
| 1276 | $this->applyFilter($name, 'trim'); |
|
| 1277 | ||
| 1278 | if ($required) { |
|
| 1279 | $this->addRule($name, get_lang('ThisFieldIsRequired'), 'required'); |
|
| 1280 | } |
|
| 1281 | ||
| 1282 | $this->addRule( |
|
| 1283 | $name, |
|
| 1284 | get_lang('OnlyLettersAndNumbersAndSpaces'), |
|
| 1285 | 'regex', |
|
| 1286 | '/^[a-zA-Z0-9ñÑ\s]+$/' |
|
| 1287 | ); |
|
| 1288 | } |
|
| 1289 | ||
| 1290 | /** |
|
| 1291 | * @param string $url |
|
| 1292 | */ |
|
| @@ 1114-1151 (lines=38) @@ | ||
| 1111 | * @param bool $required Optional. Is the form-element required (default=true) |
|
| 1112 | * @param array $attributes Optional. List of attributes for the form-element |
|
| 1113 | */ |
|
| 1114 | public function addTextLettersOnly( |
|
| 1115 | $name, |
|
| 1116 | $label, |
|
| 1117 | $required = false, |
|
| 1118 | $attributes = [] |
|
| 1119 | ) { |
|
| 1120 | $attributes = array_merge( |
|
| 1121 | $attributes, |
|
| 1122 | [ |
|
| 1123 | 'pattern' => '[a-zA-ZñÑ]+', |
|
| 1124 | 'title' => get_lang('OnlyLetters') |
|
| 1125 | ] |
|
| 1126 | ); |
|
| 1127 | ||
| 1128 | $this->addElement( |
|
| 1129 | 'text', |
|
| 1130 | $name, |
|
| 1131 | [ |
|
| 1132 | $label, |
|
| 1133 | get_lang('OnlyLetters') |
|
| 1134 | ], |
|
| 1135 | $attributes |
|
| 1136 | ); |
|
| 1137 | ||
| 1138 | $this->applyFilter($name, 'trim'); |
|
| 1139 | ||
| 1140 | if ($required) { |
|
| 1141 | $this->addRule($name, get_lang('ThisFieldIsRequired'), 'required'); |
|
| 1142 | } |
|
| 1143 | ||
| 1144 | $this->addRule( |
|
| 1145 | $name, |
|
| 1146 | get_lang('OnlyLetters'), |
|
| 1147 | 'regex', |
|
| 1148 | '/^[a-zA-ZñÑ]+$/' |
|
| 1149 | ); |
|
| 1150 | } |
|
| 1151 | ||
| 1152 | /** |
|
| 1153 | * Adds a text field for alphanumeric characters to the form. |
|
| 1154 | * A trim-filter is attached to the field. |
|
| @@ 1160-1197 (lines=38) @@ | ||
| 1157 | * @param bool $required Optional. Is the form-element required (default=true) |
|
| 1158 | * @param array $attributes Optional. List of attributes for the form-element |
|
| 1159 | */ |
|
| 1160 | public function addTextAlphanumeric( |
|
| 1161 | $name, |
|
| 1162 | $label, |
|
| 1163 | $required = false, |
|
| 1164 | $attributes = [] |
|
| 1165 | ) { |
|
| 1166 | $attributes = array_merge( |
|
| 1167 | $attributes, |
|
| 1168 | [ |
|
| 1169 | 'pattern' => '[a-zA-Z0-9ñÑ]+', |
|
| 1170 | 'title' => get_lang('OnlyLettersAndNumbers') |
|
| 1171 | ] |
|
| 1172 | ); |
|
| 1173 | ||
| 1174 | $this->addElement( |
|
| 1175 | 'text', |
|
| 1176 | $name, |
|
| 1177 | [ |
|
| 1178 | $label, |
|
| 1179 | get_lang('OnlyLettersAndNumbers') |
|
| 1180 | ], |
|
| 1181 | $attributes |
|
| 1182 | ); |
|
| 1183 | ||
| 1184 | $this->applyFilter($name, 'trim'); |
|
| 1185 | ||
| 1186 | if ($required) { |
|
| 1187 | $this->addRule($name, get_lang('ThisFieldIsRequired'), 'required'); |
|
| 1188 | } |
|
| 1189 | ||
| 1190 | $this->addRule( |
|
| 1191 | $name, |
|
| 1192 | get_lang('OnlyLettersAndNumbers'), |
|
| 1193 | 'regex', |
|
| 1194 | '/^[a-zA-Z0-9ÑÑ]+$/' |
|
| 1195 | ); |
|
| 1196 | } |
|
| 1197 | ||
| 1198 | /** |
|
| 1199 | * Adds a text field for letters and spaces to the form. |
|
| 1200 | * A trim-filter is attached to the field. |
|
| @@ 1206-1243 (lines=38) @@ | ||
| 1203 | * @param bool $required Optional. Is the form-element required (default=true) |
|
| 1204 | * @param array $attributes Optional. List of attributes for the form-element |
|
| 1205 | */ |
|
| 1206 | public function addTextLettersAndSpaces( |
|
| 1207 | $name, |
|
| 1208 | $label, |
|
| 1209 | $required = false, |
|
| 1210 | $attributes = [] |
|
| 1211 | ) { |
|
| 1212 | $attributes = array_merge( |
|
| 1213 | $attributes, |
|
| 1214 | [ |
|
| 1215 | 'pattern' => '[a-zA-ZñÑ\s]+', |
|
| 1216 | 'title' => get_lang('OnlyLettersAndSpaces') |
|
| 1217 | ] |
|
| 1218 | ); |
|
| 1219 | ||
| 1220 | $this->addElement( |
|
| 1221 | 'text', |
|
| 1222 | $name, |
|
| 1223 | [ |
|
| 1224 | $label, |
|
| 1225 | get_lang('OnlyLettersAndSpaces') |
|
| 1226 | ], |
|
| 1227 | $attributes |
|
| 1228 | ); |
|
| 1229 | ||
| 1230 | $this->applyFilter($name, 'trim'); |
|
| 1231 | ||
| 1232 | if ($required) { |
|
| 1233 | $this->addRule($name, get_lang('ThisFieldIsRequired'), 'required'); |
|
| 1234 | } |
|
| 1235 | ||
| 1236 | $this->addRule( |
|
| 1237 | $name, |
|
| 1238 | get_lang('OnlyLettersAndSpaces'), |
|
| 1239 | 'regex', |
|
| 1240 | '/^[a-zA-ZñÑ\s]+$/' |
|
| 1241 | ); |
|
| 1242 | } |
|
| 1243 | ||
| 1244 | /** |
|
| 1245 | * Adds a text field for alphanumeric and spaces characters to the form. |
|
| 1246 | * A trim-filter is attached to the field. |
|