Skip to content

Move attributes to php-forge/html-attributes package. #340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9568ecf
Move `attributes` to `php-forge/html-attributes` package.
terabytesoftw Feb 29, 2024
8da4634
Apply fixes from StyleCI
StyleCIBot Feb 29, 2024
07b9f62
Refactor field attribute generation.
terabytesoftw Feb 29, 2024
13bd8ea
Apply fixes from StyleCI
StyleCIBot Feb 29, 2024
5b6acf5
Refactor form control classes and fix label issue.
terabytesoftw Feb 29, 2024
ba66fdc
Apply fixes from StyleCI
StyleCIBot Feb 29, 2024
a697f0a
Refactor attribute setting in AbstractSvg class.
terabytesoftw Feb 29, 2024
14092a7
Add HasForm attribute to AbstractButton, AbstractInput, AbstractInput…
terabytesoftw Mar 1, 2024
60f8dee
Fix name attribute in all tags.
terabytesoftw Mar 1, 2024
3133719
More refactor widgets.
terabytesoftw Mar 2, 2024
261ebd2
Apply fixes from StyleCI
StyleCIBot Mar 2, 2024
8bbb4a3
Update namespace for FormControl\Input classes.
terabytesoftw Mar 2, 2024
bf956eb
Update form control attributes in the codebase.
terabytesoftw Mar 2, 2024
333e142
Fix validation error in AbstractSelect.php.
terabytesoftw Mar 2, 2024
fa124cd
Delete HasDataValue trait.
terabytesoftw Mar 2, 2024
07082c5
Refactor testGenerateField method to testFieldAttributes.
terabytesoftw Mar 2, 2024
ae7105f
Add dirname attribute to input elements.
terabytesoftw Mar 2, 2024
fe00422
Update composer.json and form control classes.
terabytesoftw Mar 2, 2024
c172a43
Update exception messages in form control input widgets.
terabytesoftw Mar 3, 2024
56d362d
Better structure.
terabytesoftw Mar 3, 2024
de9f447
Update form control classes and remove unused test classes.
terabytesoftw Mar 4, 2024
347d581
Apply fixes from StyleCI
StyleCIBot Mar 4, 2024
b3d562b
Fix ecs tests.
terabytesoftw Mar 4, 2024
44129f9
Refactor attribute imports in PHPForge classes.
terabytesoftw Mar 4, 2024
0fcef0e
Apply fixes from StyleCI
StyleCIBot Mar 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
- Enh #338: Move `Helper` classes to `php-forge/html-helper` package (@terabytesoftw)
- Enh #339: Move interface `ContentInterface::class` and `LabelInterface::class` to `php-forge/html-interop` package
(@terabytesoftw)
- Enh #340: Move `attributes` classes to `php-forge/html-attributes` package (@terabytesoftw)

## 0.2.0 February 27, 2024

5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -16,8 +16,9 @@
"ext-mbstring": "*",
"enshrined/svg-sanitize": "^0.17.0",
"php-forge/awesome-widget": "^0.1.2",
"php-forge/html-helper": "^0.1",
"php-forge/html-interop": "^0.1",
"php-forge/html-attribute": "dev-main",
"php-forge/html-helper": "dev-main",
"php-forge/html-interop": "^0.3",
"voku/anti-xss": "^4.1"
},
"require-dev": {
25 changes: 15 additions & 10 deletions docs/form-control/Button.md
Original file line number Diff line number Diff line change
@@ -120,6 +120,11 @@ The following methods are available for setting attributes:
| `class()` | Set the `class` attribute. |
| `content()` | Set the `content` within the `button` element. |
| `dataAttributes()` | Set multiple `data-attributes` at once. |
| `formaction()` | Set the `formaction` attribute. |
| `formenctype()` | Set the `formenctype` attribute. |
| `formmethod()` | Set the `formmethod` attribute. |
| `formnovalidate()` | Set the `formnovalidate` attribute. |
| `formtarget()` | Set the `formtarget` attribute. |
| `id()` | Set the `id` attribute. |
| `lang()` | Set the `lang` attribute. |
| `name()` | Set the `name` attribute. |
@@ -143,17 +148,17 @@ The following methods are available for customizing the `HTML` output:
| `containerAttributes()` | Set `attributes` for the `container` element. |
| `containerClass()` | Set the `class` attribute for the `container` element. |
| `containerTag()` | Set the `tag` for the `container` element. |
| `prefix()` | Add text before the `button` element. |
| `prefixContainer()` | Set enabled or disabled for the `prefix-container` element. |
| `prefixContainerAttributes()`| Set `attributes` for the `prefix-container` element. |
| `prefixContainerClass()` | Set the `class` attribute for the `prefix-container` element. |
| `prefixContainerTag()` | Set the `tag` for the `prefix-container`. |
| `prefix()` | Add text before the `tag` element. If empty, the `prefix` tag will be disabled. |
| `prefixAttributes()` | Set `attributes` for the `prefix` element. |
| `prefixClass()` | Set the `class` attribute for the `prefix` element. |
| `prefixTag()` | Set the `tag` for the `prefix` element. |
| | If `false` the prefix tag will be disabled. |
| `render()` | Generates the `HTML` output. |
| `suffix()` | Add text after the `button` element. |
| `suffixContainer()` | Set enabled or disabled for the `suffix-container` element. |
| `suffixContainerAttributes()`| Set `attributes` for the `suffix-container` element. |
| `suffixContainerClass()` | Set the `class` attribute for the `suffix-container` element. |
| `suffixContainerTag()` | Set the `tag` for the `suffix-container` element. |
| `suffix()` | Add text after the `tag` element. If empty, the `suffix` tag will be disabled. |
| `suffixAttributes()` | Set `attributes` for the `suffix` element. |
| `suffixClass()` | Set the `class` attribute for the `suffix` element. |
| `suffixTag()` | Set the `tag` for the `suffix-container` element. |
| | If `false` the suffix tag will be disabled. |
| `tagName()` | Set the `tag` for the `button` element. |
| | Allowed values: `a`, `button`. |
| `template()` | Set the `template` for the `button` element. |
23 changes: 13 additions & 10 deletions docs/form-control/Label.md
Original file line number Diff line number Diff line change
@@ -33,6 +33,9 @@ If you want to include content within the `label` tag, use the `content` method.
$label->content('MyContent');
```

> if content is empty, the `label` tag will not be rendered.


## Rendering

Generate the `HTML` output using the `render` method.
@@ -120,16 +123,16 @@ The following methods are available for customizing the `HTML` output:

| Method | Description |
| ---------------------------- | ------------------------------------------------------------------------------------- |
| `prefix()` | Add text before the `label` element. |
| `prefixContainer()` | Set enabled or disabled for the `prefix-container` element. |
| `prefixContainerAttributes()`| Set `attributes` for the `prefix-container` element. |
| `prefixContainerClass()` | Set the `class` attribute for the `prefix-container` element. |
| `prefixContainerTag()` | Set the `tag` for the `prefix-container` element. |
| `prefix()` | Add text before the `tag` element. If empty, the `prefix` tag will be disabled. |
| `prefixAttributes()` | Set `attributes` for the `prefix` element. |
| `prefixClass()` | Set the `class` attribute for the `prefix` element. |
| `prefixTag()` | Set the `tag` for the `prefix` element. |
| | If `false` the prefix tag will be disabled. |
| `render()` | Generates the `HTML` output. |
| `suffix()` | Add text after the `label` element. |
| `suffixContainer()` | Set enabled or disabled for the `suffix-container` element. |
| `suffixContainerAttributes()`| Set `attributes` for the `suffix-container` element. |
| `suffixContainerClass()` | Set the `class` attribute for the `suffix-container` element. |
| `suffixContainerTag()` | Set the `tag` for the `suffix-container` element. |
| `suffix()` | Add text after the `tag` element. If empty, the `suffix` tag will be disabled. |
| `suffixAttributes()` | Set `attributes` for the `suffix` element. |
| `suffixClass()` | Set the `class` attribute for the `suffix` element. |
| `suffixTag()` | Set the `tag` for the `suffix-container` element. |
| | If `false` the suffix tag will be disabled. |
| `template()` | Set the `template` for the `label` element. |
| `widget()` | Instantiates the `Label::class`. |
35 changes: 18 additions & 17 deletions docs/form-control/Select.md
Original file line number Diff line number Diff line change
@@ -12,17 +12,16 @@ $select = Select::widget();

## Generate field id and name

The `generateField` method is used to generate the field id and name for the `HTML` output.
The `fieldAttributes` method is used to generate the field id and name for the `HTML` output.

Allowed arguments are:

- `modelName` - The name of the model.
- `fieldName` - The name of the field.
- `arrayable` - Whether the field is an array. For default, it is `false`.
- `formModel` - The name of the model.
- `property` - The name of the field.

```php
// generate field id and name
$select->generateField('model', 'field');
$select->fieldAttributes('model', 'field');
```

## Setting Attributes
@@ -205,6 +204,7 @@ The following methods are available for setting attributes:
| ----------------- | ------------------------------------------------------------------------------------------------ |
| `ariaLabel()` | Set the `aria-label` attribute. |
| `attributes()` | Set multiple `attributes` at once. |
| `autocomplete()` | Set the `autocomplete` attribute. |
| `autofocus()` | Set the `autofocus` attribute. |
| `class()` | Set the `class` attribute. |
| `disabled()` | Set the `disabled` attribute. |
@@ -227,23 +227,24 @@ The following methods are available for customizing the `HTML` output:

| Method | Description |
| ---------------------------- | ------------------------------------------------------------------------------------- |
| `disableLabel()` | Set enabled or disabled for the `label` element. |
| `fieldAttributes()` | Set `attributes` for the `field` element. |
| `groups()` | Add `groups` to the `select` element. |
| `items()` | Add `items` to the `select` element. |
| `itemsAttributes()` | Add `attributes` to the `items` element. |
| `groups()` | Add `groups` to the `select` element. |
| `labelAttributes()` | Set `attributes` for the `label` element. |
| `labelClass()` | Set the `class` attribute for the `label` element. |
| `labelContent()` | Set the `content` for the `label` element. |
| `labelFor()` | Set the `for` attribute for the `label` element. |
| `notLabel()` | Set enabled or disabled for the `label` element. |
| `prefix()` | Add text before the `select` element. |
| `prefixContainer()` | Set enabled or disabled for the `prefix-container` element. |
| `prefixContainerAttributes()`| Set `attributes` for the `prefix-container` element. |
| `prefixContainerClass()` | Set the `class` attribute for the `prefix-container` element. |
| `prefixContainerTag()` | Set the `tag` for the `prefix-container` element. |
| `prefix()` | Add text before the `tag` element. If empty, the `prefix` tag will be disabled. |
| `prefixAttributes()` | Set `attributes` for the `prefix` element. |
| `prefixClass()` | Set the `class` attribute for the `prefix` element. |
| `prefixTag()` | Set the `tag` for the `prefix` element. |
| | If `false` the prefix tag will be disabled. |
| `render()` | Generates the `HTML` output. |
| `suffix()` | Add text after the `select` element. |
| `suffixContainer()` | Set enabled or disabled for the `suffix-container` element. |
| `suffixContainerAttributes()`| Set `attributes` for the `suffix-container` element. |
| `suffixContainerClass()` | Set the `class` attribute for the `suffix-container` element. |
| `suffixContainerTag()` | Set the `tag` for the `suffix-container` element. |
| `suffix()` | Add text after the `tag` element. If empty, the `suffix` tag will be disabled. |
| `suffixAttributes()` | Set `attributes` for the `suffix` element. |
| `suffixClass()` | Set the `class` attribute for the `suffix` element. |
| `suffixTag()` | Set the `tag` for the `suffix-container` element. |
| | If `false` the suffix tag will be disabled. |
| `widget()` | Instantiates the `Select::class`. |
31 changes: 15 additions & 16 deletions docs/form-control/TextArea.md
Original file line number Diff line number Diff line change
@@ -13,17 +13,16 @@ $textArea = TextArea::widget();

## Generate field id and name

The `generateField` method is used to generate the field id and name for the `HTML` output.
The `fieldAttributes` method is used to generate the field id and name for the `HTML` output.

Allowed arguments are:

- `modelName` - The name of the model.
- `fieldName` - The name of the field.
- `arrayable` - Whether the field is an array. For default, it is `false`.
- `formModel` - The name of the model.
- `property` - The name of the field.

```php
// generate field id and name
$textArea->generateField('model', 'field');
$textArea->fieldAttributes('model', 'field');
```

## Setting Attributes
@@ -146,18 +145,18 @@ The following methods are available for customizing the `HTML` output:

| Method | Description |
| ---------------------------- | ------------------------------------------------------------------------------------- |
| `generateField()` | Generate the field id and name for the `HTML` output. |
| `prefix()` | Add text before the `textarea` element. |
| `prefixContainer()` | Set enabled or disabled for the `prefix-container` element. |
| `prefixContainerAttributes()`| Set `attributes` for the `prefix-container` element. |
| `prefixContainerClass()` | Set the `class` attribute for the `prefix-container` element. |
| `prefixContainerTag()` | Set the `tag` for the `prefix-container` element. |
| `fieldAttributes()` | Generate the field id and name for the `HTML` output. |
| `prefix()` | Add text before the `tag` element. If empty, the `prefix` tag will be disabled. |
| `prefixAttributes()` | Set `attributes` for the `prefix` element. |
| `prefixClass()` | Set the `class` attribute for the `prefix` element. |
| `prefixTag()` | Set the `tag` for the `prefix` element. |
| | If `false` the prefix tag will be disabled. |
| `render()` | Generates the `HTML` output. |
| `suffix()` | Add text after the `label` element. |
| `suffixContainer()` | Set enabled or disabled for the `suffix-container` element. |
| `suffixContainerAttributes()`| Set `attributes` for the `suffix-container` element. |
| `suffixContainerClass()` | Set the `class` attribute for the `suffix-container` element. |
| `suffixContainerTag()` | Set the `tag` for the `suffix-container` element. |
| `suffix()` | Add text after the `tag` element. If empty, the `suffix` tag will be disabled. |
| `suffixAttributes()` | Set `attributes` for the `suffix` element. |
| `suffixClass()` | Set the `class` attribute for the `suffix` element. |
| `suffixTag()` | Set the `tag` for the `suffix-container` element. |
| | If `false` the suffix tag will be disabled. |
| `template()` | Set the template for the `HTML` output. |
| `tokenValues()` | Set the token values for the `HTML` output. |
| `widget()` | Instantiates the `TextArea::class`. |
Loading