Form of Aura

18 views
Skip to first unread message

Thị Đài Trang Lê

unread,
Mar 27, 2015, 4:06:35 AM3/27/15
to aur...@googlegroups.com

Dear,
      I use Aura.Web_Project and I created a project in Aura/quick-starts... I want to use form in Aura, so I follow the instruction in here:
http://auraphp.com/manuals/2.0/en/forms/
I put form.php in Aura/quick-starts/web which its code like:

<?php
/**
 * {$PROJECT_PATH}/src/App/Input/ContactForm.php
 */
namespace App\Input;

use Aura\Input\Form;

class ContactForm extends Form
{
    public function init()
    {
        $states = array(
            'AL' => 'Alabama',
            'AK' => 'Alaska',
            'AZ' => 'Arizona',
            'AR' => 'Arkansas',
            // ...
        );
        // this will make sure all field names are setup as an array so you can get all fields through $_POST['contact']
        $this->setName('contact');
        // set input fields
        // hint the view layer to treat the first_name field as a text input,
        // with size and maxlength attributes
        $this->setField('first_name', 'text')
            ->setAttribs(array(
                'id' => 'first_name',
                'size' => 20,
                'maxlength' => 20,
            ));

        // hint the view layer to treat the state field as a select, with a
        // particular set of options (the keys are the option values,
        // and the values are the displayed text)
        $this->setField('state', 'select')
            ->setAttribs(array(
                 'id' => 'state',
            ))
            ->setOptions($states);

        $this->setField('message', 'textarea')
            ->setAttribs([
                'id' => 'message',
                'cols' => 40,
                'rows' => 5,
            ]);
        // etc.

        // get filter object
        $filter = $this->getFilter();
        // set your filters.
        $filter->addSoftRule('first_name', $filter::IS, 'string');
        $filter->addSoftRule('first_name', $filter::IS, 'strlenMin', 4);
        $filter->addSoftRule('state', $filter::IS, 'inKeys', array_keys($states));
        $filter->addSoftRule('message', $filter::IS, 'string');
        $filter->addSoftRule('message', $filter::IS, 'strlenMin', 6);
    }
}

And the error picture is above. Would you mind helping me?
Thank you very much!

Hari K T

unread,
Mar 27, 2015, 4:11:58 AM3/27/15
to aur...@googlegroups.com
      I use Aura.Web_Project and I created a project in Aura/quick-starts... I want to use form in Aura, so I follow the instruction in here:
http://auraphp.com/manuals/2.0/en/forms/
I put form.php in Aura/quick-starts/web which its code like:

Read again the comments in the code. Where is the path shown? Just don't copy and paste .
Next time I don't :-)  if you don't read the code what is written .
Reply all
Reply to author
Forward
0 new messages