| @@ 1308-1345 (lines=38) @@ | ||
| 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 | public function addTextLettersOnly( |
|
| 1309 | $name, |
|
| 1310 | $label, |
|
| 1311 | $required = false, |
|
| 1312 | $attributes = [] |
|
| 1313 | ) { |
|
| 1314 | $attributes = array_merge( |
|
| 1315 | $attributes, |
|
| 1316 | [ |
|
| 1317 | 'pattern' => '[a-zA-ZñÑ]+', |
|
| 1318 | 'title' => get_lang('OnlyLetters') |
|
| 1319 | ] |
|
| 1320 | ); |
|
| 1321 | ||
| 1322 | $this->addElement( |
|
| 1323 | 'text', |
|
| 1324 | $name, |
|
| 1325 | [ |
|
| 1326 | $label, |
|
| 1327 | get_lang('OnlyLetters') |
|
| 1328 | ], |
|
| 1329 | $attributes |
|
| 1330 | ); |
|
| 1331 | ||
| 1332 | $this->applyFilter($name, 'trim'); |
|
| 1333 | ||
| 1334 | if ($required) { |
|
| 1335 | $this->addRule($name, get_lang('ThisFieldIsRequired'), 'required'); |
|
| 1336 | } |
|
| 1337 | ||
| 1338 | $this->addRule( |
|
| 1339 | $name, |
|
| 1340 | get_lang('OnlyLetters'), |
|
| 1341 | 'regex', |
|
| 1342 | '/^[a-zA-ZñÑ]+$/' |
|
| 1343 | ); |
|
| 1344 | } |
|
| 1345 | ||
| 1346 | /** |
|
| 1347 | * Adds a text field for alphanumeric characters to the form. |
|
| 1348 | * A trim-filter is attached to the field. |
|
| @@ 1354-1391 (lines=38) @@ | ||
| 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 | public function addTextAlphanumeric( |
|
| 1355 | $name, |
|
| 1356 | $label, |
|
| 1357 | $required = false, |
|
| 1358 | $attributes = [] |
|
| 1359 | ) { |
|
| 1360 | $attributes = array_merge( |
|
| 1361 | $attributes, |
|
| 1362 | [ |
|
| 1363 | 'pattern' => '[a-zA-Z0-9ñÑ]+', |
|
| 1364 | 'title' => get_lang('OnlyLettersAndNumbers') |
|
| 1365 | ] |
|
| 1366 | ); |
|
| 1367 | ||
| 1368 | $this->addElement( |
|
| 1369 | 'text', |
|
| 1370 | $name, |
|
| 1371 | [ |
|
| 1372 | $label, |
|
| 1373 | get_lang('OnlyLettersAndNumbers') |
|
| 1374 | ], |
|
| 1375 | $attributes |
|
| 1376 | ); |
|
| 1377 | ||
| 1378 | $this->applyFilter($name, 'trim'); |
|
| 1379 | ||
| 1380 | if ($required) { |
|
| 1381 | $this->addRule($name, get_lang('ThisFieldIsRequired'), 'required'); |
|
| 1382 | } |
|
| 1383 | ||
| 1384 | $this->addRule( |
|
| 1385 | $name, |
|
| 1386 | get_lang('OnlyLettersAndNumbers'), |
|
| 1387 | 'regex', |
|
| 1388 | '/^[a-zA-Z0-9ÑÑ]+$/' |
|
| 1389 | ); |
|
| 1390 | } |
|
| 1391 | ||
| 1392 | /** |
|
| 1393 | * @param string $name |
|
| 1394 | * @param $label |
|
| @@ 1479-1516 (lines=38) @@ | ||
| 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 | public function addTextLettersAndSpaces( |
|
| 1480 | $name, |
|
| 1481 | $label, |
|
| 1482 | $required = false, |
|
| 1483 | $attributes = [] |
|
| 1484 | ) { |
|
| 1485 | $attributes = array_merge( |
|
| 1486 | $attributes, |
|
| 1487 | [ |
|
| 1488 | 'pattern' => '[a-zA-ZñÑ\s]+', |
|
| 1489 | 'title' => get_lang('OnlyLettersAndSpaces') |
|
| 1490 | ] |
|
| 1491 | ); |
|
| 1492 | ||
| 1493 | $this->addElement( |
|
| 1494 | 'text', |
|
| 1495 | $name, |
|
| 1496 | [ |
|
| 1497 | $label, |
|
| 1498 | get_lang('OnlyLettersAndSpaces') |
|
| 1499 | ], |
|
| 1500 | $attributes |
|
| 1501 | ); |
|
| 1502 | ||
| 1503 | $this->applyFilter($name, 'trim'); |
|
| 1504 | ||
| 1505 | if ($required) { |
|
| 1506 | $this->addRule($name, get_lang('ThisFieldIsRequired'), 'required'); |
|
| 1507 | } |
|
| 1508 | ||
| 1509 | $this->addRule( |
|
| 1510 | $name, |
|
| 1511 | get_lang('OnlyLettersAndSpaces'), |
|
| 1512 | 'regex', |
|
| 1513 | '/^[a-zA-ZñÑ\s]+$/' |
|
| 1514 | ); |
|
| 1515 | } |
|
| 1516 | ||
| 1517 | /** |
|
| 1518 | * Adds a text field for alphanumeric and spaces characters to the form. |
|
| 1519 | * A trim-filter is attached to the field. |
|
| @@ 1525-1562 (lines=38) @@ | ||
| 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 | public function addTextAlphanumericAndSpaces( |
|
| 1526 | $name, |
|
| 1527 | $label, |
|
| 1528 | $required = false, |
|
| 1529 | $attributes = [] |
|
| 1530 | ) { |
|
| 1531 | $attributes = array_merge( |
|
| 1532 | $attributes, |
|
| 1533 | [ |
|
| 1534 | 'pattern' => '[a-zA-Z0-9ñÑ\s]+', |
|
| 1535 | 'title' => get_lang('OnlyLettersAndNumbersAndSpaces') |
|
| 1536 | ] |
|
| 1537 | ); |
|
| 1538 | ||
| 1539 | $this->addElement( |
|
| 1540 | 'text', |
|
| 1541 | $name, |
|
| 1542 | [ |
|
| 1543 | $label, |
|
| 1544 | get_lang('OnlyLettersAndNumbersAndSpaces') |
|
| 1545 | ], |
|
| 1546 | $attributes |
|
| 1547 | ); |
|
| 1548 | ||
| 1549 | $this->applyFilter($name, 'trim'); |
|
| 1550 | ||
| 1551 | if ($required) { |
|
| 1552 | $this->addRule($name, get_lang('ThisFieldIsRequired'), 'required'); |
|
| 1553 | } |
|
| 1554 | ||
| 1555 | $this->addRule( |
|
| 1556 | $name, |
|
| 1557 | get_lang('OnlyLettersAndNumbersAndSpaces'), |
|
| 1558 | 'regex', |
|
| 1559 | '/^[a-zA-Z0-9ñÑ\s]+$/' |
|
| 1560 | ); |
|
| 1561 | } |
|
| 1562 | ||
| 1563 | /** |
|
| 1564 | * @param string $url |
|
| 1565 | */ |
|