Giter Club home page Giter Club logo

cform's People

Contributors

mosbth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cform's Issues

Check for CSRF

Implement a check to avoid CSRF attacks by storing a key in session.

Wrong exception when using a validation rule that does not exist.

This is what I get when using a rule that does not exist ->

Fatal error: Class 'Mos\HTMLForm\Exception' not found in /var/www/kmom4/vendor/mos/cform/src/HTMLForm/CFormElement.php on line 351

Looks like the Exception class is not in the right namespace. Expected error and namespace should be like below.

// CFormElement.php line 350
if (!isset($tests[$rule])) {
    throw new \Exception("Validation of form element failed, no such validation rule exists: $rule");
}

I changed Exception() to \Exception() and it should now work.

Using CForm without session fails

When using CForm without a session, error messages will appear. Improve by either make a control in the constructor that the session is started, or silently fail for session features.

unexpected *check* behavior

Description

I look at the v2 branch since this seems to be served using composer.

I try to validate a form without any callback specified. This will never return true because lines 563-566 in CForm::check(..) always yield $ret = $callbackStatus which defaults to null ( see line 415).
The following (see code example) therefor never enters the success block.

        $status = $form->check();

        if ($status === true) {...
              success: redirect...
        } else if($status===false){...
        }

I suggest to change the initialization in line 415 from
$callbackStatus = null;
to
$callbackStatus = true;
which gives the expected behavior.

Example code

same as in the guide http://dbwebb.se/kunskap/anvand-cform-tillsammans-med-anax-mvc
but without callbacks,


class FormsController extends CApplicationBasic {

    public function indexAction() {

        $form = $this->di->get('form');

        $form = $form->create([], [
            'name' => [
              'type'        => 'text',
              'label'       => 'Name of contact person:',
              'required'    => true,
              'validation'  => ['not_empty'],
            ],
            'email' => [
              'type'        => 'text',
              'required'    => true,
              'validation'  => ['not_empty', 'email_adress'],
            ],
            'phone' => [
              'type'        => 'text',
              'required'    => true,
              'validation'  => ['not_empty', 'numeric'],
            ],
            'submit' => [
                'type'      => 'submit',
            ],
            'submit-fail' => [
                'type'      => 'submit',
            ],
        ]);

            // Check the status of the form
        $status = $form->check();

        if ($status === true) {

            // What to do if the form was submitted?
            $form->AddOUtput("<p><i>Form was submitted and the callback method returned true.</i></p>");
            $this->redirectTo('');

        } else if ($status === false) {

            // What to do when form could not be processed?
            $form->AddOutput("<p><i>Form was submitted and the Check() method returned false.</i></p>");
        }


        $this->di->theme->setTitle("Test the Form");
        $this->di->views->add('default/content', [
            'content' => $form->getHTML()
        ]);

    }
}

CLydia not exists

Error is:
Classfile 'CLydia' does not exists.
#0 [internal function]: myAutoloader('CLydia')
#1 [internal function]: spl_autoload_call('CLydia')
#2 /apache2/htdocs/dataDB/vendor/mos/cform/src/HTMLForm/CFormElement.php(37): is_callable('CLydia::Instanc...')

Line 37 in CFormElement and the _construct()

    public function __construct($name, $attributes = []) 
    {
        $this->attributes = $attributes;    
        $this['name'] = $name;
        //$this['key'] = $name;
        //$this['name'] = isset($this['name']) ? $this['name'] : $name;

        // Use character encoding from lydia if available, else use UTF-8 OBSOLETE, remove this.
        if (is_callable('CLydia::Instance()')) {
            $this->characterEncoding = CLydia::Instance()->config['character_encoding'];
        } else {
            $this->characterEncoding = 'UTF-8';
        }
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.