[NFR]: Forms should transform "" to NULL unless explicitly told not to
Open
@niden is already working on this.
Since Jul 14, 2026.
7.0
new feature request
- Dominant language
- PHP
- Stars
- 10.8k
- Forks
- 1.9k
- Avg merge
- 7h 2m
- Merged PRs (30d)
- 47
Description
Database
CREATE TABLE `accommodation` (
...
`website` VARCHAR(60) DEFAULT NULL
...
Controller
// Request a transaction
$transaction = $this->transactionManager->get();
$accommodation = new Accommodation();
$accommodation->setTransaction($transaction);
...
$accommodationForm->bind(
$_POST,
$accommodation,
[
...
'website',
...
]
);
if ($accommodation->create() == false) {
$transaction->rollback(__('Error has occured while creating accommodation'), $accommodation);
}
...
// no errors, commit changes
$transaction->commit();
Form
// website input
$website = new Text('website');
$website->setLabel(__('Website'));
/*$website->addValidator(
new Url(
[
"message" => __('Please enter valid website address')
]
)
);*/
$this->add($website);
Expected behavior
DB field should be null when nothing was entered in the field
Actual behavior
DB field is empty string
Details
- Phalcon version: 3.4.0
- PHP Version: 7.2.8
- Operating System: macOS
- Installation type: Compiling from source
- Server: Nginx
- Database: MySQL 8.0.12
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.