Skip to content

scaffold: wrong getPost type #1468

@andersonmendess

Description

@andersonmendess

Questions should go to https://forum.phalconphp.com
Documentation issues should go to https://github.com/phalcon/docs/issues

Expected and Actual Behavior

CREATE TABLE `users` (
  `name` varchar(255) NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

$user = new Users();
$user->name = $this->request->getPost("name", "string");
CREATE TABLE `users` (
  `name` varchar(255) NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

$user = new Users();
$user->name = $this->request->getPost("name", "int");

Describe what you are trying to achieve and what goes wrong.

I'm just following documentation: https://docs.phalcon.io/4.0/en/devtools
issue:
the controller generated by scaffold are setting ->getPost("field","int") for all data type, even text.

Provide output if related

CREATE TABLE `users` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `password` char(60) NOT NULL,
  `active` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

result:

        $user = new Users();
        $user->name = $this->request->getPost("name", "int");
        $user->email = $this->request->getPost("email", "int");
        $user->password = $this->request->getPost("password", "int");
        $user->active = $this->request->getPost("active", "int");

Provide minimal script to reproduce the issue

just follow the official guide https://docs.phalcon.io/4.0/en/devtools

Details

  • System info and versions (if possible): (phalcon info)
Phalcon DevTools (4.0.1)

Environment:
  OS: Linux anderson-pc 5.6.19-2-MANJARO #1 SMP PREEMPT Wed Jun 17 22:24:52 UTC 2020 x86_64
  PHP Version: 7.4.8
  PHP SAPI: cli
  PHP Bin: /usr/bin/php
  PHP Extension Dir: /usr/lib/php/modules
  PHP Bin Dir: /usr/bin
  Loaded PHP config: /etc/php/php.ini
Versions:
  Phalcon DevTools Version: 4.0.1
  Phalcon Version: 4.0.6
  AdminLTE Version: 2.3.6
  • Phalcon Framework version: (php --ri phalcon)
phalcon


Phalcon is a full stack PHP framework, delivered as a PHP extension, offering lower resource consumption and high performance.
phalcon => enabled
Author => Phalcon Team and contributors
Version => 4.0.6
Build Date => Jul 28 2020 22:58:26
Powered by Zephir => Version 0.12.17-6724dbf

Directive => Local Value => Master Value
phalcon.db.escape_identifiers => On => On
phalcon.db.force_casting => Off => Off
phalcon.orm.case_insensitive_column_map => Off => Off
phalcon.orm.cast_last_insert_id_to_int => Off => Off
phalcon.orm.cast_on_hydrate => Off => Off
phalcon.orm.column_renaming => On => On
phalcon.orm.disable_assign_setters => Off => Off
phalcon.orm.enable_implicit_joins => On => On
phalcon.orm.enable_literals => On => On
phalcon.orm.events => On => On
phalcon.orm.exception_on_failed_save => Off => Off
phalcon.orm.exception_on_failed_metadata_save => On => On
phalcon.orm.ignore_unknown_columns => Off => Off
phalcon.orm.late_state_binding => Off => Off
phalcon.orm.not_null_validations => On => On
phalcon.orm.update_snapshot_on_save => On => On
phalcon.orm.virtual_foreign_keys => On => On
phalcon.warning.enable => On => On
  • PHP Version: (php -v)
PHP 7.4.8 (cli) (built: Jul 10 2020 09:59:22) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
  • Operating System:
    OS: Manjaro 20.0.3 Lysia
    Kernel: x86_64 Linux 5.6.19-2-MANJARO

  • Server: Nginx | Apache | Other
    official phalcon-devtools server

  • Other related info (Database, table schema):
    MySQL

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions