@@ 1257-1294 (lines=38) @@ | ||
1254 | * @param bool $required Optional. Is the form-element required (default=true) |
|
1255 | * @param array $attributes Optional. List of attributes for the form-element |
|
1256 | */ |
|
1257 | public function addTextLettersOnly( |
|
1258 | $name, |
|
1259 | $label, |
|
1260 | $required = false, |
|
1261 | $attributes = [] |
|
1262 | ) { |
|
1263 | $attributes = array_merge( |
|
1264 | $attributes, |
|
1265 | [ |
|
1266 | 'pattern' => '[a-zA-ZñÑ]+', |
|
1267 | 'title' => get_lang('OnlyLetters') |
|
1268 | ] |
|
1269 | ); |
|
1270 | ||
1271 | $this->addElement( |
|
1272 | 'text', |
|
1273 | $name, |
|
1274 | [ |
|
1275 | $label, |
|
1276 | get_lang('OnlyLetters') |
|
1277 | ], |
|
1278 | $attributes |
|
1279 | ); |
|
1280 | ||
1281 | $this->applyFilter($name, 'trim'); |
|
1282 | ||
1283 | if ($required) { |
|
1284 | $this->addRule($name, get_lang('ThisFieldIsRequired'), 'required'); |
|
1285 | } |
|
1286 | ||
1287 | $this->addRule( |
|
1288 | $name, |
|
1289 | get_lang('OnlyLetters'), |
|
1290 | 'regex', |
|
1291 | '/^[a-zA-ZñÑ]+$/' |
|
1292 | ); |
|
1293 | } |
|
1294 | ||
1295 | /** |
|
1296 | * Adds a text field for alphanumeric characters to the form. |
|
1297 | * A trim-filter is attached to the field. |
|
@@ 1303-1340 (lines=38) @@ | ||
1300 | * @param bool $required Optional. Is the form-element required (default=true) |
|
1301 | * @param array $attributes Optional. List of attributes for the form-element |
|
1302 | */ |
|
1303 | public function addTextAlphanumeric( |
|
1304 | $name, |
|
1305 | $label, |
|
1306 | $required = false, |
|
1307 | $attributes = [] |
|
1308 | ) { |
|
1309 | $attributes = array_merge( |
|
1310 | $attributes, |
|
1311 | [ |
|
1312 | 'pattern' => '[a-zA-Z0-9ñÑ]+', |
|
1313 | 'title' => get_lang('OnlyLettersAndNumbers') |
|
1314 | ] |
|
1315 | ); |
|
1316 | ||
1317 | $this->addElement( |
|
1318 | 'text', |
|
1319 | $name, |
|
1320 | [ |
|
1321 | $label, |
|
1322 | get_lang('OnlyLettersAndNumbers') |
|
1323 | ], |
|
1324 | $attributes |
|
1325 | ); |
|
1326 | ||
1327 | $this->applyFilter($name, 'trim'); |
|
1328 | ||
1329 | if ($required) { |
|
1330 | $this->addRule($name, get_lang('ThisFieldIsRequired'), 'required'); |
|
1331 | } |
|
1332 | ||
1333 | $this->addRule( |
|
1334 | $name, |
|
1335 | get_lang('OnlyLettersAndNumbers'), |
|
1336 | 'regex', |
|
1337 | '/^[a-zA-Z0-9ÑÑ]+$/' |
|
1338 | ); |
|
1339 | } |
|
1340 | ||
1341 | /** |
|
1342 | * @param $name |
|
1343 | * @param $label |
|
@@ 1428-1465 (lines=38) @@ | ||
1425 | * @param bool $required Optional. Is the form-element required (default=true) |
|
1426 | * @param array $attributes Optional. List of attributes for the form-element |
|
1427 | */ |
|
1428 | public function addTextLettersAndSpaces( |
|
1429 | $name, |
|
1430 | $label, |
|
1431 | $required = false, |
|
1432 | $attributes = [] |
|
1433 | ) { |
|
1434 | $attributes = array_merge( |
|
1435 | $attributes, |
|
1436 | [ |
|
1437 | 'pattern' => '[a-zA-ZñÑ\s]+', |
|
1438 | 'title' => get_lang('OnlyLettersAndSpaces') |
|
1439 | ] |
|
1440 | ); |
|
1441 | ||
1442 | $this->addElement( |
|
1443 | 'text', |
|
1444 | $name, |
|
1445 | [ |
|
1446 | $label, |
|
1447 | get_lang('OnlyLettersAndSpaces') |
|
1448 | ], |
|
1449 | $attributes |
|
1450 | ); |
|
1451 | ||
1452 | $this->applyFilter($name, 'trim'); |
|
1453 | ||
1454 | if ($required) { |
|
1455 | $this->addRule($name, get_lang('ThisFieldIsRequired'), 'required'); |
|
1456 | } |
|
1457 | ||
1458 | $this->addRule( |
|
1459 | $name, |
|
1460 | get_lang('OnlyLettersAndSpaces'), |
|
1461 | 'regex', |
|
1462 | '/^[a-zA-ZñÑ\s]+$/' |
|
1463 | ); |
|
1464 | } |
|
1465 | ||
1466 | /** |
|
1467 | * Adds a text field for alphanumeric and spaces characters to the form. |
|
1468 | * A trim-filter is attached to the field. |
|
@@ 1474-1511 (lines=38) @@ | ||
1471 | * @param bool $required Optional. Is the form-element required (default=true) |
|
1472 | * @param array $attributes Optional. List of attributes for the form-element |
|
1473 | */ |
|
1474 | public function addTextAlphanumericAndSpaces( |
|
1475 | $name, |
|
1476 | $label, |
|
1477 | $required = false, |
|
1478 | $attributes = [] |
|
1479 | ) { |
|
1480 | $attributes = array_merge( |
|
1481 | $attributes, |
|
1482 | [ |
|
1483 | 'pattern' => '[a-zA-Z0-9ñÑ\s]+', |
|
1484 | 'title' => get_lang('OnlyLettersAndNumbersAndSpaces') |
|
1485 | ] |
|
1486 | ); |
|
1487 | ||
1488 | $this->addElement( |
|
1489 | 'text', |
|
1490 | $name, |
|
1491 | [ |
|
1492 | $label, |
|
1493 | get_lang('OnlyLettersAndNumbersAndSpaces') |
|
1494 | ], |
|
1495 | $attributes |
|
1496 | ); |
|
1497 | ||
1498 | $this->applyFilter($name, 'trim'); |
|
1499 | ||
1500 | if ($required) { |
|
1501 | $this->addRule($name, get_lang('ThisFieldIsRequired'), 'required'); |
|
1502 | } |
|
1503 | ||
1504 | $this->addRule( |
|
1505 | $name, |
|
1506 | get_lang('OnlyLettersAndNumbersAndSpaces'), |
|
1507 | 'regex', |
|
1508 | '/^[a-zA-Z0-9ñÑ\s]+$/' |
|
1509 | ); |
|
1510 | } |
|
1511 | ||
1512 | /** |
|
1513 | * @param string $url |
|
1514 | */ |