https://github.com/liesauer/qlplugin-simpleform
make form submission easier
https://github.com/liesauer/qlplugin-simpleform
Last synced: about 1 month ago
JSON representation
make form submission easier
- Host: GitHub
- URL: https://github.com/liesauer/qlplugin-simpleform
- Owner: liesauer
- Created: 2017-09-28T06:23:06.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-03T04:35:47.000Z (over 7 years ago)
- Last Synced: 2025-04-08T17:46:12.836Z (about 1 month ago)
- Language: PHP
- Homepage:
- Size: 4.88 KB
- Stars: 3
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# QueryList V4 Plugin - SimpleForm
make form submission easier
# Installation
```
composer require liesauer/ql-plugin-simpleform
```
# Bind
* QueryList `simpleForm` ($formUrl, $formSelector = '', $formParams = [], $postParams = [], ...$args)
* `formUrl` where to get the form
* `formSelector` only required if there are two or more form elements
* `formParams` use for get the form, read `QueryList::get` or `QueryList::post`, default method is get
* `postParams` same as `formParams` but use for form submission, default method is post
* `args` no used
# Usage
```php
use liesauer\QLPlugin\SimpleForm;
use QL\QueryList;require_once __DIR__ . '/vendor/autoload.php';
// cookie needed for this example
$cookie = new \GuzzleHttp\Cookie\CookieJar();$ql = QueryList::getInstance();
// use this plugin
$ql->use(SimpleForm::class);$username = $ql->simpleForm('https://github.com/login', '', [
'options' => [
'verify' => false,
'cookies' => $cookie,
],
], [
'params' => [
'login' => 'username',
'password' => 'password',
],
'options' => [
'verify' => false,
'cookies' => $cookie,
],
])->find('.header-nav-current-user>.css-truncate-target')->text();if (!empty($username)) {
echo "welcome back, {$username}!\n";
} else {
$error = $ql->find('.flash-error>.container')->text();
echo "{$error}\n";
}
```