https://github.com/n2ref/coreui-form-php
https://github.com/n2ref/coreui-form-php
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/n2ref/coreui-form-php
- Owner: n2ref
- License: mit
- Created: 2023-04-23T13:02:45.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-26T10:28:53.000Z (over 1 year ago)
- Last Synced: 2025-01-01T04:00:57.866Z (over 1 year ago)
- Language: PHP
- Size: 102 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Coreui form
[Online documentation](https://n2ref.github.io/coreui-form)
### Install
```shell
composer install n2ref/coreui-form
```
### Example usage
```php
use CoreUI\Form;
$form = new Form('id');
$form->setTitle('Title');
$form->setLang('en');
$form->setLangItems([ 'www' => 'eee']);
$form->setSend('/url/path', 'post', 'form');
$form->setValidResponseHeaders([ 'Content-Type': ['application/json'] ]);
$form->setValidResponseType([ 'json' ]);
$form->setWidth(600);
$form->setWidthMin(600);
$form->setWidthMax(600);
$form->setWidthLabel(200);
$form->setWidthFields(200);
$form->setControlsOffset(200);
$form->setReadonly(true);
$form->setValidate(true);
$form->setSuccessLoadUrl('/url/path');
$form->setErrorClass('bg-danger');
$form->setOnSubmit('return func()');
$form->setOnSubmitSuccess('return func2()');
$form->setLayout(
'
' .
'' .
'Position
' .
'[position_default]' .
'' .
''
);
$form->setRecord([
'text' => 'default text value',
'textarea' => "123",
'date' => "2023-01-01"
]);
$form->addFields([
(new Form\Field\Text('text', 'Text'))->setWidth(200)
->attachFields([
(new Form\Field\Text('text', 'Text2'))->setRequired(true)
]),
(new Form\Field\TextArea('textarea', 'Text Area'))->setWidth(200)->setDescription("123"),
(new Form\Field\Group('Group name', true))
->addFields([
(new Form\Field\Date('date', 'Date'))->setWidth(200)->setAttr("class", "text-danger")
])
]);
$form->addControls([
(new Form\Control\Submit('Save'))->setWidth(200)
(new Form\Control\Link('Link', 'url/path'))
]);
$form->toArray();
```